Coverage Report

Created: 2026-01-21 06:59

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
471k
#define CONCAT(a, b) CONCAT_(a, b)
49
471k
#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
757k
{
81
757k
  SStream_concat(OS, "%s%s", markup("<reg:"),
82
757k
           getRegisterName(Reg, AArch64_NoRegAltName));
83
757k
  SStream_concat0(OS, markup(">"));
84
757k
}
85
86
void printRegNameAlt(SStream *OS, unsigned Reg, unsigned AltIdx)
87
168k
{
88
168k
  SStream_concat(OS, "%s%s", markup("<reg:"),
89
168k
           getRegisterName(Reg, AltIdx));
90
168k
  SStream_concat0(OS, markup(">"));
91
168k
}
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
374k
{
100
374k
  bool isAlias = false;
101
374k
  bool useAliasDetails = map_use_alias_details(MI);
102
374k
  map_set_fill_detail_ops(MI, useAliasDetails);
103
104
374k
  unsigned Opcode = MCInst_getOpcode(MI);
105
106
374k
  if (Opcode == AArch64_SYSxt) {
107
4.13k
    if (printSysAlias(MI, O)) {
108
1.08k
      isAlias = true;
109
1.08k
      MCInst_setIsAlias(MI, isAlias);
110
1.08k
      if (useAliasDetails)
111
1.08k
        return;
112
1.08k
    }
113
4.13k
  }
114
115
373k
  if (Opcode == AArch64_SYSPxt || Opcode == AArch64_SYSPxt_XZR) {
116
4.18k
    if (printSyspAlias(MI, O)) {
117
2.18k
      isAlias = true;
118
2.18k
      MCInst_setIsAlias(MI, isAlias);
119
2.18k
      if (useAliasDetails)
120
2.18k
        return;
121
2.18k
    }
122
4.18k
  }
123
124
  // RPRFM overlaps PRFM (reg), so try to print it as RPRFM here.
125
371k
  if ((Opcode == AArch64_PRFMroX) || (Opcode == AArch64_PRFMroW)) {
126
217
    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
217
  }
133
134
  // SBFM/UBFM should print to a nicer aliased form if possible.
135
371k
  if (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri ||
136
369k
      Opcode == AArch64_UBFMXri || Opcode == AArch64_UBFMWri) {
137
5.08k
    MCOperand *Op0 = MCInst_getOperand(MI, (0));
138
5.08k
    MCOperand *Op1 = MCInst_getOperand(MI, (1));
139
5.08k
    MCOperand *Op2 = MCInst_getOperand(MI, (2));
140
5.08k
    MCOperand *Op3 = MCInst_getOperand(MI, (3));
141
142
5.08k
    bool IsSigned = (Opcode == AArch64_SBFMXri ||
143
3.41k
         Opcode == AArch64_SBFMWri);
144
5.08k
    bool Is64Bit = (Opcode == AArch64_SBFMXri ||
145
3.41k
        Opcode == AArch64_UBFMXri);
146
5.08k
    if (MCOperand_isImm(Op2) && MCOperand_getImm(Op2) == 0 &&
147
3.78k
        MCOperand_isImm(Op3)) {
148
3.78k
      const char *AsmMnemonic = NULL;
149
150
3.78k
      switch (MCOperand_getImm(Op3)) {
151
658
      default:
152
658
        break;
153
1.84k
      case 7:
154
1.84k
        if (IsSigned)
155
713
          AsmMnemonic = "sxtb";
156
1.12k
        else if (!Is64Bit)
157
803
          AsmMnemonic = "uxtb";
158
1.84k
        break;
159
982
      case 15:
160
982
        if (IsSigned)
161
511
          AsmMnemonic = "sxth";
162
471
        else if (!Is64Bit)
163
304
          AsmMnemonic = "uxth";
164
982
        break;
165
301
      case 31:
166
        // *xtw is only valid for signed 64-bit operations.
167
301
        if (Is64Bit && IsSigned)
168
119
          AsmMnemonic = "sxtw";
169
301
        break;
170
3.78k
      }
171
172
3.78k
      if (AsmMnemonic) {
173
2.45k
        SStream_concat(O, "%s", AsmMnemonic);
174
2.45k
        SStream_concat0(O, " ");
175
176
2.45k
        printRegName(O, MCOperand_getReg(Op0));
177
2.45k
        SStream_concat0(O, ", ");
178
2.45k
        printRegName(O, getWRegFromXReg(
179
2.45k
              MCOperand_getReg(Op1)));
180
2.45k
        if (detail_is_set(MI) && useAliasDetails) {
181
2.45k
          AArch64_set_detail_op_reg(
182
2.45k
            MI, 0, MCOperand_getReg(Op0));
183
2.45k
          AArch64_set_detail_op_reg(
184
2.45k
            MI, 1,
185
2.45k
            getWRegFromXReg(
186
2.45k
              MCOperand_getReg(Op1)));
187
2.45k
          if (strings_match(AsmMnemonic, "uxtb"))
188
803
            AArch64_get_detail_op(MI, -1)
189
803
              ->ext =
190
803
              AARCH64_EXT_UXTB;
191
1.64k
          else if (strings_match(AsmMnemonic,
192
1.64k
                     "sxtb"))
193
713
            AArch64_get_detail_op(MI, -1)
194
713
              ->ext =
195
713
              AARCH64_EXT_SXTB;
196
934
          else if (strings_match(AsmMnemonic,
197
934
                     "uxth"))
198
304
            AArch64_get_detail_op(MI, -1)
199
304
              ->ext =
200
304
              AARCH64_EXT_UXTH;
201
630
          else if (strings_match(AsmMnemonic,
202
630
                     "sxth"))
203
511
            AArch64_get_detail_op(MI, -1)
204
511
              ->ext =
205
511
              AARCH64_EXT_SXTH;
206
119
          else if (strings_match(AsmMnemonic,
207
119
                     "sxtw"))
208
119
            AArch64_get_detail_op(MI, -1)
209
119
              ->ext =
210
119
              AARCH64_EXT_SXTW;
211
0
          else
212
0
            AArch64_get_detail_op(MI, -1)
213
0
              ->ext =
214
0
              AARCH64_EXT_INVALID;
215
2.45k
        }
216
2.45k
        isAlias = true;
217
2.45k
        MCInst_setIsAlias(MI, isAlias);
218
2.45k
        if (useAliasDetails)
219
2.45k
          return;
220
0
        else
221
0
          goto add_real_detail;
222
2.45k
      }
223
3.78k
    }
224
225
    // All immediate shifts are aliases, implemented using the Bitfield
226
    // instruction. In all cases the immediate shift amount shift must be in
227
    // the range 0 to (reg.size -1).
228
2.63k
    if (MCOperand_isImm(Op2) && MCOperand_isImm(Op3)) {
229
2.63k
      const char *AsmMnemonic = NULL;
230
2.63k
      int shift = 0;
231
2.63k
      int64_t immr = MCOperand_getImm(Op2);
232
2.63k
      int64_t imms = MCOperand_getImm(Op3);
233
2.63k
      if (Opcode == AArch64_UBFMWri && imms != 0x1F &&
234
549
          ((imms + 1) == immr)) {
235
69
        AsmMnemonic = "lsl";
236
69
        shift = 31 - imms;
237
2.56k
      } else if (Opcode == AArch64_UBFMXri && imms != 0x3f &&
238
1.12k
           ((imms + 1 == immr))) {
239
156
        AsmMnemonic = "lsl";
240
156
        shift = 63 - imms;
241
2.40k
      } else if (Opcode == AArch64_UBFMWri && imms == 0x1f) {
242
40
        AsmMnemonic = "lsr";
243
40
        shift = immr;
244
2.36k
      } else if (Opcode == AArch64_UBFMXri && imms == 0x3f) {
245
68
        AsmMnemonic = "lsr";
246
68
        shift = immr;
247
2.29k
      } else if (Opcode == AArch64_SBFMWri && imms == 0x1f) {
248
69
        AsmMnemonic = "asr";
249
69
        shift = immr;
250
2.22k
      } else if (Opcode == AArch64_SBFMXri && imms == 0x3f) {
251
80
        AsmMnemonic = "asr";
252
80
        shift = immr;
253
80
      }
254
2.63k
      if (AsmMnemonic) {
255
482
        SStream_concat(O, "%s", AsmMnemonic);
256
482
        SStream_concat0(O, " ");
257
258
482
        printRegName(O, MCOperand_getReg(Op0));
259
482
        SStream_concat0(O, ", ");
260
482
        printRegName(O, MCOperand_getReg(Op1));
261
482
        SStream_concat(O, "%s%s#%d", ", ",
262
482
                 markup("<imm:"), shift);
263
482
        SStream_concat0(O, markup(">"));
264
482
        if (detail_is_set(MI) && useAliasDetails) {
265
482
          AArch64_set_detail_op_reg(
266
482
            MI, 0, MCOperand_getReg(Op0));
267
482
          AArch64_set_detail_op_reg(
268
482
            MI, 1, MCOperand_getReg(Op1));
269
482
          if (strings_match(AsmMnemonic, "lsl"))
270
225
            AArch64_get_detail_op(MI, -1)
271
225
              ->shift.type =
272
225
              AARCH64_SFT_LSL;
273
257
          else if (strings_match(AsmMnemonic,
274
257
                     "lsr"))
275
108
            AArch64_get_detail_op(MI, -1)
276
108
              ->shift.type =
277
108
              AARCH64_SFT_LSR;
278
149
          else if (strings_match(AsmMnemonic,
279
149
                     "asr"))
280
149
            AArch64_get_detail_op(MI, -1)
281
149
              ->shift.type =
282
149
              AARCH64_SFT_ASR;
283
0
          else
284
0
            AArch64_get_detail_op(MI, -1)
285
0
              ->shift.type =
286
0
              AARCH64_SFT_INVALID;
287
482
          AArch64_get_detail_op(MI, -1)
288
482
            ->shift.value = shift;
289
482
        }
290
482
        isAlias = true;
291
482
        MCInst_setIsAlias(MI, isAlias);
292
482
        if (useAliasDetails)
293
482
          return;
294
0
        else
295
0
          goto add_real_detail;
296
482
      }
297
2.63k
    }
298
299
    // SBFIZ/UBFIZ aliases
300
2.14k
    if (MCOperand_getImm(Op2) > MCOperand_getImm(Op3)) {
301
778
      SStream_concat(O, "%s", (IsSigned ? "sbfiz" : "ubfiz"));
302
778
      SStream_concat0(O, " ");
303
304
778
      printRegName(O, MCOperand_getReg(Op0));
305
778
      SStream_concat0(O, ", ");
306
778
      printRegName(O, MCOperand_getReg(Op1));
307
778
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
308
778
      printUInt32Bang(O, (Is64Bit ? 64 : 32) -
309
778
               MCOperand_getImm(Op2));
310
778
      SStream_concat(O, "%s%s%s", markup(">"), ", ",
311
778
               markup("<imm:"));
312
778
      printInt64Bang(O, MCOperand_getImm(Op3) + 1);
313
778
      SStream_concat0(O, markup(">"));
314
778
      if (detail_is_set(MI) && useAliasDetails) {
315
778
        AArch64_set_detail_op_reg(
316
778
          MI, 0, MCOperand_getReg(Op0));
317
778
        AArch64_set_detail_op_reg(
318
778
          MI, 1, MCOperand_getReg(Op1));
319
778
        AArch64_set_detail_op_imm(
320
778
          MI, 2, AARCH64_OP_IMM,
321
778
          (Is64Bit ? 64 : 32) -
322
778
            MCOperand_getImm(Op2));
323
778
        AArch64_set_detail_op_imm(
324
778
          MI, 3, AARCH64_OP_IMM,
325
778
          MCOperand_getImm(Op3) + 1);
326
778
      }
327
778
      isAlias = true;
328
778
      MCInst_setIsAlias(MI, isAlias);
329
778
      if (useAliasDetails)
330
778
        return;
331
0
      else
332
0
        goto add_real_detail;
333
778
    }
334
335
    // Otherwise SBFX/UBFX is the preferred form
336
1.37k
    SStream_concat(O, "%s", (IsSigned ? "sbfx" : "ubfx"));
337
1.37k
    SStream_concat0(O, " ");
338
339
1.37k
    printRegName(O, MCOperand_getReg(Op0));
340
1.37k
    SStream_concat0(O, ", ");
341
1.37k
    printRegName(O, MCOperand_getReg(Op1));
342
1.37k
    SStream_concat(O, "%s%s", ", ", markup("<imm:"));
343
1.37k
    printInt64Bang(O, MCOperand_getImm(Op2));
344
1.37k
    SStream_concat(O, "%s%s%s", markup(">"), ", ", markup("<imm:"));
345
1.37k
    printInt64Bang(O, MCOperand_getImm(Op3) -
346
1.37k
            MCOperand_getImm(Op2) + 1);
347
1.37k
    SStream_concat0(O, markup(">"));
348
1.37k
    if (detail_is_set(MI) && useAliasDetails) {
349
1.37k
      AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0));
350
1.37k
      AArch64_set_detail_op_reg(MI, 1, MCOperand_getReg(Op1));
351
1.37k
      AArch64_set_detail_op_imm(MI, 2, AARCH64_OP_IMM,
352
1.37k
              MCOperand_getImm(Op2));
353
1.37k
      AArch64_set_detail_op_imm(
354
1.37k
        MI, 3, AARCH64_OP_IMM,
355
1.37k
        MCOperand_getImm(Op3) - MCOperand_getImm(Op2) +
356
1.37k
          1);
357
1.37k
    }
358
1.37k
    isAlias = true;
359
1.37k
    MCInst_setIsAlias(MI, isAlias);
360
1.37k
    if (useAliasDetails)
361
1.37k
      return;
362
0
    else
363
0
      goto add_real_detail;
364
1.37k
  }
365
366
366k
  if (Opcode == AArch64_BFMXri || Opcode == AArch64_BFMWri) {
367
1.74k
    isAlias = true;
368
1.74k
    MCInst_setIsAlias(MI, isAlias);
369
1.74k
    MCOperand *Op0 = MCInst_getOperand(MI, (0)); // Op1 == Op0
370
1.74k
    MCOperand *Op2 = MCInst_getOperand(MI, (2));
371
1.74k
    int ImmR = MCOperand_getImm(MCInst_getOperand(MI, (3)));
372
1.74k
    int ImmS = MCOperand_getImm(MCInst_getOperand(MI, (4)));
373
374
1.74k
    if ((MCOperand_getReg(Op2) == AArch64_WZR ||
375
1.65k
         MCOperand_getReg(Op2) == AArch64_XZR) &&
376
893
        (ImmR == 0 || ImmS < ImmR) &&
377
398
        (AArch64_getFeatureBits(MI->csh->mode,
378
398
              AArch64_FeatureAll) ||
379
0
         AArch64_getFeatureBits(MI->csh->mode,
380
398
              AArch64_HasV8_2aOps))) {
381
      // BFC takes precedence over its entire range, sligtly differently
382
      // to BFI.
383
398
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
384
398
      int LSB = (BitWidth - ImmR) % BitWidth;
385
398
      int Width = ImmS + 1;
386
387
398
      SStream_concat0(O, "bfc ");
388
398
      printRegName(O, MCOperand_getReg(Op0));
389
398
      SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"),
390
398
               LSB);
391
398
      SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
392
398
               markup("<imm:"), Width);
393
398
      SStream_concat0(O, markup(">"));
394
398
      if (detail_is_set(MI) && useAliasDetails) {
395
398
        AArch64_set_detail_op_reg(
396
398
          MI, 0, MCOperand_getReg(Op0));
397
398
        AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM,
398
398
                LSB);
399
398
        AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM,
400
398
                Width);
401
398
      }
402
403
398
      if (useAliasDetails)
404
398
        return;
405
0
      else
406
0
        goto add_real_detail;
407
1.34k
    } else if (ImmS < ImmR) {
408
      // BFI alias
409
358
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
410
358
      int LSB = (BitWidth - ImmR) % BitWidth;
411
358
      int Width = ImmS + 1;
412
413
358
      SStream_concat0(O, "bfi ");
414
358
      printRegName(O, MCOperand_getReg(Op0));
415
358
      SStream_concat0(O, ", ");
416
358
      printRegName(O, MCOperand_getReg(Op2));
417
358
      SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"),
418
358
               LSB);
419
358
      SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
420
358
               markup("<imm:"), Width);
421
358
      SStream_concat0(O, markup(">"));
422
358
      if (detail_is_set(MI) && useAliasDetails) {
423
358
        AArch64_set_detail_op_reg(
424
358
          MI, 0, MCOperand_getReg(Op0));
425
358
        AArch64_set_detail_op_reg(
426
358
          MI, 2, MCOperand_getReg(Op2));
427
358
        AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM,
428
358
                LSB);
429
358
        AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM,
430
358
                Width);
431
358
      }
432
358
      if (useAliasDetails)
433
358
        return;
434
0
      else
435
0
        goto add_real_detail;
436
358
    }
437
438
984
    int LSB = ImmR;
439
984
    int Width = ImmS - ImmR + 1;
440
    // Otherwise BFXIL the preferred form
441
984
    SStream_concat0(O, "bfxil ");
442
984
    printRegName(O, MCOperand_getReg(Op0));
443
984
    SStream_concat0(O, ", ");
444
984
    printRegName(O, MCOperand_getReg(Op2));
445
984
    SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"), LSB);
446
984
    SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
447
984
             markup("<imm:"), Width);
448
984
    SStream_concat0(O, markup(">"));
449
984
    if (detail_is_set(MI) && useAliasDetails) {
450
984
      AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0));
451
984
      AArch64_set_detail_op_reg(MI, 2, MCOperand_getReg(Op2));
452
984
      AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM, LSB);
453
984
      AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM, Width);
454
984
    }
455
984
    if (useAliasDetails)
456
984
      return;
457
984
  }
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
364k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi ||
463
363k
       Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
464
1.47k
      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
364k
  if ((Opcode == AArch64_MOVKXi || Opcode == AArch64_MOVKWi) &&
473
1.86k
      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
364k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi) &&
487
789
      MCOperand_isImm(MCInst_getOperand(MI, (1))) &&
488
789
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
489
789
    int RegWidth = Opcode == AArch64_MOVZXi ? 64 : 32;
490
789
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2)));
491
789
    uint64_t Value =
492
789
      (uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1)))
493
789
      << Shift;
494
495
789
    if (AArch64_AM_isMOVZMovAlias(
496
789
          Value, Shift, Opcode == AArch64_MOVZXi ? 64 : 32)) {
497
688
      isAlias = true;
498
688
      MCInst_setIsAlias(MI, isAlias);
499
688
      SStream_concat0(O, "mov ");
500
688
      printRegName(O, MCOperand_getReg(
501
688
            MCInst_getOperand(MI, (0))));
502
688
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
503
688
      printInt64Bang(O, SignExtend64(Value, RegWidth));
504
688
      SStream_concat0(O, markup(">"));
505
688
      if (detail_is_set(MI) && useAliasDetails) {
506
688
        AArch64_set_detail_op_reg(
507
688
          MI, 0, MCInst_getOpVal(MI, 0));
508
688
        AArch64_set_detail_op_imm(
509
688
          MI, 1, AARCH64_OP_IMM,
510
688
          SignExtend64(Value, RegWidth));
511
688
      }
512
688
      if (useAliasDetails)
513
688
        return;
514
688
    }
515
789
  }
516
517
363k
  if ((Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
518
688
      MCOperand_isImm(MCInst_getOperand(MI, (1))) &&
519
688
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
520
688
    int RegWidth = Opcode == AArch64_MOVNXi ? 64 : 32;
521
688
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2)));
522
688
    uint64_t Value =
523
688
      ~((uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1)))
524
688
        << Shift);
525
688
    if (RegWidth == 32)
526
296
      Value = Value & 0xffffffff;
527
528
688
    if (AArch64_AM_isMOVNMovAlias(Value, Shift, RegWidth)) {
529
634
      isAlias = true;
530
634
      MCInst_setIsAlias(MI, isAlias);
531
634
      SStream_concat0(O, "mov ");
532
634
      printRegName(O, MCOperand_getReg(
533
634
            MCInst_getOperand(MI, (0))));
534
634
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
535
634
      printInt64Bang(O, SignExtend64(Value, RegWidth));
536
634
      SStream_concat0(O, markup(">"));
537
634
      if (detail_is_set(MI) && useAliasDetails) {
538
634
        AArch64_set_detail_op_reg(
539
634
          MI, 0, MCInst_getOpVal(MI, 0));
540
634
        AArch64_set_detail_op_imm(
541
634
          MI, 1, AARCH64_OP_IMM,
542
634
          SignExtend64(Value, RegWidth));
543
634
      }
544
634
      if (useAliasDetails)
545
634
        return;
546
634
    }
547
688
  }
548
549
363k
  if ((Opcode == AArch64_ORRXri || Opcode == AArch64_ORRWri) &&
550
2.92k
      (MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_XZR ||
551
1.28k
       MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_WZR) &&
552
1.89k
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
553
1.89k
    int RegWidth = Opcode == AArch64_ORRXri ? 64 : 32;
554
1.89k
    uint64_t Value = AArch64_AM_decodeLogicalImmediate(
555
1.89k
      MCOperand_getImm(MCInst_getOperand(MI, (2))), RegWidth);
556
1.89k
    if (!AArch64_AM_isAnyMOVWMovAlias(Value, RegWidth)) {
557
1.08k
      isAlias = true;
558
1.08k
      MCInst_setIsAlias(MI, isAlias);
559
1.08k
      SStream_concat0(O, "mov ");
560
1.08k
      printRegName(O, MCOperand_getReg(
561
1.08k
            MCInst_getOperand(MI, (0))));
562
1.08k
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
563
1.08k
      printInt64Bang(O, SignExtend64(Value, RegWidth));
564
1.08k
      SStream_concat0(O, markup(">"));
565
1.08k
      if (detail_is_set(MI) && useAliasDetails) {
566
1.08k
        AArch64_set_detail_op_reg(
567
1.08k
          MI, 0, MCInst_getOpVal(MI, 0));
568
1.08k
        AArch64_set_detail_op_imm(
569
1.08k
          MI, 2, AARCH64_OP_IMM,
570
1.08k
          SignExtend64(Value, RegWidth));
571
1.08k
      }
572
1.08k
      if (useAliasDetails)
573
1.08k
        return;
574
1.08k
    }
575
1.89k
  }
576
577
362k
  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
362k
  if (!isAlias)
592
362k
    isAlias |= printAliasInstr(MI, Address, O);
593
594
362k
add_real_detail:
595
362k
  MCInst_setIsAlias(MI, isAlias);
596
597
362k
  if (!isAlias || !useAliasDetails) {
598
323k
    map_set_fill_detail_ops(MI, !(isAlias && useAliasDetails));
599
323k
    if (isAlias)
600
0
      SStream_Close(O);
601
323k
    printInstruction(MI, Address, O);
602
323k
    if (isAlias)
603
0
      SStream_Open(O);
604
323k
  }
605
362k
}
606
607
bool printRangePrefetchAlias(MCInst *MI, SStream *O, const char *Annot)
608
217
{
609
217
  unsigned Opcode = MCInst_getOpcode(MI);
610
611
217
#ifndef NDEBUG
612
613
217
#endif
614
615
217
  unsigned PRFOp = MCOperand_getImm(MCInst_getOperand(MI, (0)));
616
217
  unsigned Mask = 0x18; // 0b11000
617
217
  if ((PRFOp & Mask) != Mask)
618
217
    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
217
}
655
656
bool printSysAlias(MCInst *MI, SStream *O)
657
4.13k
{
658
4.13k
  MCOperand *Op1 = MCInst_getOperand(MI, (0));
659
4.13k
  MCOperand *Cn = MCInst_getOperand(MI, (1));
660
4.13k
  MCOperand *Cm = MCInst_getOperand(MI, (2));
661
4.13k
  MCOperand *Op2 = MCInst_getOperand(MI, (3));
662
663
4.13k
  unsigned Op1Val = MCOperand_getImm(Op1);
664
4.13k
  unsigned CnVal = MCOperand_getImm(Cn);
665
4.13k
  unsigned CmVal = MCOperand_getImm(Cm);
666
4.13k
  unsigned Op2Val = MCOperand_getImm(Op2);
667
668
4.13k
  uint16_t Encoding = Op2Val;
669
4.13k
  Encoding |= CmVal << 3;
670
4.13k
  Encoding |= CnVal << 7;
671
4.13k
  Encoding |= Op1Val << 11;
672
673
4.13k
  bool NeedsReg;
674
4.13k
  const char *Ins;
675
4.13k
  const char *Name;
676
677
4.13k
  if (CnVal == 7) {
678
2.46k
    switch (CmVal) {
679
313
    default:
680
313
      return false;
681
    // Maybe IC, maybe Prediction Restriction
682
147
    case 1:
683
147
      switch (Op1Val) {
684
35
      default:
685
35
        return false;
686
41
      case 0:
687
41
        goto Search_IC;
688
71
      case 3:
689
71
        goto Search_PRCTX;
690
147
      }
691
    // Prediction Restriction aliases
692
214
    case 3: {
693
285
Search_PRCTX:
694
285
      if (Op1Val != 3 || CnVal != 7 || CmVal != 3)
695
107
        return false;
696
697
178
      unsigned int Requires =
698
178
        Op2Val == 6 ? AArch64_FeatureSPECRES2 :
699
178
                AArch64_FeaturePredRes;
700
178
      if (!(AArch64_getFeatureBits(MI->csh->mode,
701
178
                 AArch64_FeatureAll) ||
702
0
            AArch64_getFeatureBits(MI->csh->mode, Requires)))
703
0
        return false;
704
705
178
      NeedsReg = true;
706
178
      switch (Op2Val) {
707
67
      default:
708
67
        return false;
709
25
      case 4:
710
25
        Ins = "cfp ";
711
25
        break;
712
3
      case 5:
713
3
        Ins = "dvp ";
714
3
        break;
715
8
      case 6:
716
8
        Ins = "cosp ";
717
8
        break;
718
75
      case 7:
719
75
        Ins = "cpp ";
720
75
        break;
721
178
      }
722
111
      Name = "RCTX";
723
111
    } break;
724
    // IC aliases
725
96
    case 5: {
726
137
Search_IC: {
727
137
  const AArch64IC_IC *IC = AArch64IC_lookupICByEncoding(Encoding);
728
137
  if (!IC ||
729
85
      !AArch64_testFeatureList(MI->csh->mode, IC->FeaturesRequired))
730
52
    return false;
731
85
  if (detail_is_set(MI)) {
732
85
    aarch64_sysop sysop = { 0 };
733
85
    sysop.reg = IC->SysReg;
734
85
    sysop.sub_type = AARCH64_OP_IC;
735
85
    AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
736
85
    AArch64_get_detail_op(MI, 0)->sysop = sysop;
737
85
    AArch64_inc_op_count(MI);
738
85
  }
739
740
85
  NeedsReg = IC->NeedsReg;
741
85
  Ins = "ic ";
742
85
  Name = IC->Name;
743
85
}
744
85
    } break;
745
    // DC aliases
746
470
    case 4:
747
506
    case 6:
748
543
    case 10:
749
615
    case 11:
750
634
    case 12:
751
708
    case 13:
752
1.50k
    case 14: {
753
1.50k
      const AArch64DC_DC *DC =
754
1.50k
        AArch64DC_lookupDCByEncoding(Encoding);
755
1.50k
      if (!DC || !AArch64_testFeatureList(
756
550
             MI->csh->mode, DC->FeaturesRequired))
757
951
        return false;
758
550
      if (detail_is_set(MI)) {
759
550
        aarch64_sysop sysop = { 0 };
760
550
        sysop.alias = DC->SysAlias;
761
550
        sysop.sub_type = AARCH64_OP_DC;
762
550
        AArch64_get_detail_op(MI, 0)->type =
763
550
          AARCH64_OP_SYSALIAS;
764
550
        AArch64_get_detail_op(MI, 0)->sysop = sysop;
765
550
        AArch64_inc_op_count(MI);
766
550
      }
767
768
550
      NeedsReg = true;
769
550
      Ins = "dc ";
770
550
      Name = DC->Name;
771
550
    } break;
772
    // AT aliases
773
94
    case 8:
774
196
    case 9: {
775
196
      const AArch64AT_AT *AT =
776
196
        AArch64AT_lookupATByEncoding(Encoding);
777
196
      if (!AT || !AArch64_testFeatureList(
778
90
             MI->csh->mode, AT->FeaturesRequired))
779
106
        return false;
780
781
90
      if (detail_is_set(MI)) {
782
90
        aarch64_sysop sysop = { 0 };
783
90
        sysop.alias = AT->SysAlias;
784
90
        sysop.sub_type = AARCH64_OP_AT;
785
90
        AArch64_get_detail_op(MI, 0)->type =
786
90
          AARCH64_OP_SYSALIAS;
787
90
        AArch64_get_detail_op(MI, 0)->sysop = sysop;
788
90
        AArch64_inc_op_count(MI);
789
90
      }
790
90
      NeedsReg = true;
791
90
      Ins = "at ";
792
90
      Name = AT->Name;
793
90
    } break;
794
2.46k
    }
795
2.46k
  } else if (CnVal == 8 || CnVal == 9) {
796
    // TLBI aliases
797
1.14k
    const AArch64TLBI_TLBI *TLBI =
798
1.14k
      AArch64TLBI_lookupTLBIByEncoding(Encoding);
799
1.14k
    if (!TLBI || !AArch64_testFeatureList(MI->csh->mode,
800
249
                  TLBI->FeaturesRequired))
801
897
      return false;
802
803
249
    if (detail_is_set(MI)) {
804
249
      aarch64_sysop sysop = { 0 };
805
249
      sysop.reg = TLBI->SysReg;
806
249
      sysop.sub_type = AARCH64_OP_TLBI;
807
249
      AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
808
249
      AArch64_get_detail_op(MI, 0)->sysop = sysop;
809
249
      AArch64_inc_op_count(MI);
810
249
    }
811
249
    NeedsReg = TLBI->NeedsReg;
812
249
    Ins = "tlbi ";
813
249
    Name = TLBI->Name;
814
249
  } else
815
525
    return false;
816
817
2.17k
#define TMP_STR_LEN 32
818
1.08k
  char Str[TMP_STR_LEN] = { 0 };
819
1.08k
  append_to_str_lower(Str, TMP_STR_LEN, Ins);
820
1.08k
  append_to_str_lower(Str, TMP_STR_LEN, Name);
821
1.08k
#undef TMP_STR_LEN
822
823
1.08k
  SStream_concat1(O, ' ');
824
1.08k
  SStream_concat0(O, Str);
825
1.08k
  if (NeedsReg) {
826
991
    SStream_concat0(O, ", ");
827
991
    printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (4))));
828
991
    AArch64_set_detail_op_reg(MI, 4, MCInst_getOpVal(MI, 4));
829
991
  }
830
831
1.08k
  return true;
832
4.13k
}
833
834
bool printSyspAlias(MCInst *MI, SStream *O)
835
4.18k
{
836
4.18k
  MCOperand *Op1 = MCInst_getOperand(MI, (0));
837
4.18k
  MCOperand *Cn = MCInst_getOperand(MI, (1));
838
4.18k
  MCOperand *Cm = MCInst_getOperand(MI, (2));
839
4.18k
  MCOperand *Op2 = MCInst_getOperand(MI, (3));
840
841
4.18k
  unsigned Op1Val = MCOperand_getImm(Op1);
842
4.18k
  unsigned CnVal = MCOperand_getImm(Cn);
843
4.18k
  unsigned CmVal = MCOperand_getImm(Cm);
844
4.18k
  unsigned Op2Val = MCOperand_getImm(Op2);
845
846
4.18k
  uint16_t Encoding = Op2Val;
847
4.18k
  Encoding |= CmVal << 3;
848
4.18k
  Encoding |= CnVal << 7;
849
4.18k
  Encoding |= Op1Val << 11;
850
851
4.18k
  const char *Ins;
852
4.18k
  const char *Name;
853
854
4.18k
  if (CnVal == 8 || CnVal == 9) {
855
    // TLBIP aliases
856
857
2.92k
    if (CnVal == 9) {
858
834
      if (!AArch64_getFeatureBits(MI->csh->mode,
859
834
                AArch64_FeatureAll) ||
860
834
          !AArch64_getFeatureBits(MI->csh->mode,
861
834
                AArch64_FeatureXS))
862
0
        return false;
863
834
      Encoding &= ~(1 << 7);
864
834
    }
865
866
2.92k
    const AArch64TLBI_TLBI *TLBI =
867
2.92k
      AArch64TLBI_lookupTLBIByEncoding(Encoding);
868
2.92k
    if (!TLBI || !AArch64_testFeatureList(MI->csh->mode,
869
2.18k
                  TLBI->FeaturesRequired))
870
745
      return false;
871
872
2.18k
    if (detail_is_set(MI)) {
873
2.18k
      aarch64_sysop sysop = { 0 };
874
2.18k
      sysop.reg = TLBI->SysReg;
875
2.18k
      sysop.sub_type = AARCH64_OP_TLBI;
876
2.18k
      AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
877
2.18k
      AArch64_get_detail_op(MI, 0)->sysop = sysop;
878
2.18k
      AArch64_inc_op_count(MI);
879
2.18k
    }
880
2.18k
    Ins = "tlbip ";
881
2.18k
    Name = TLBI->Name;
882
2.18k
  } else
883
1.25k
    return false;
884
885
5.02k
#define TMP_STR_LEN 32
886
2.18k
  char Str[TMP_STR_LEN] = { 0 };
887
2.18k
  append_to_str_lower(Str, TMP_STR_LEN, Ins);
888
2.18k
  append_to_str_lower(Str, TMP_STR_LEN, Name);
889
890
2.18k
  if (CnVal == 9) {
891
654
    append_to_str_lower(Str, TMP_STR_LEN, "nxs");
892
654
  }
893
2.18k
#undef TMP_STR_LEN
894
895
2.18k
  SStream_concat1(O, ' ');
896
2.18k
  SStream_concat0(O, Str);
897
2.18k
  SStream_concat0(O, ", ");
898
2.18k
  if (MCOperand_getReg(MCInst_getOperand(MI, (4))) == AArch64_XZR)
899
1.42k
    printSyspXzrPair(MI, 4, O);
900
761
  else
901
761
    CONCAT(printGPRSeqPairsClassOperand, 64)(MI, 4, O);
902
903
2.18k
  return true;
904
4.18k
}
905
906
#define DEFINE_printMatrix(EltSize) \
907
  void CONCAT(printMatrix, EltSize)(MCInst * MI, unsigned OpNum, \
908
            SStream *O) \
909
9.18k
  { \
910
9.18k
    AArch64_add_cs_detail_1( \
911
9.18k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
9.18k
      EltSize); \
913
9.18k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
9.18k
\
915
9.18k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
9.18k
    switch (EltSize) { \
917
874
    case 0: \
918
874
      break; \
919
0
    case 8: \
920
0
      SStream_concat0(O, ".b"); \
921
0
      break; \
922
1.30k
    case 16: \
923
1.30k
      SStream_concat0(O, ".h"); \
924
1.30k
      break; \
925
4.99k
    case 32: \
926
4.99k
      SStream_concat0(O, ".s"); \
927
4.99k
      break; \
928
2.00k
    case 64: \
929
2.00k
      SStream_concat0(O, ".d"); \
930
2.00k
      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
9.18k
    } \
937
9.18k
  }
printMatrix_64
Line
Count
Source
909
2.00k
  { \
910
2.00k
    AArch64_add_cs_detail_1( \
911
2.00k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
2.00k
      EltSize); \
913
2.00k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
2.00k
\
915
2.00k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
2.00k
    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
2.00k
    case 64: \
929
2.00k
      SStream_concat0(O, ".d"); \
930
2.00k
      break; \
931
0
    case 128: \
932
0
      SStream_concat0(O, ".q"); \
933
0
      break; \
934
0
    default: \
935
0
      CS_ASSERT_RET(0 && "Unsupported element size"); \
936
2.00k
    } \
937
2.00k
  }
printMatrix_32
Line
Count
Source
909
4.99k
  { \
910
4.99k
    AArch64_add_cs_detail_1( \
911
4.99k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
4.99k
      EltSize); \
913
4.99k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
4.99k
\
915
4.99k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
4.99k
    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.99k
    case 32: \
926
4.99k
      SStream_concat0(O, ".s"); \
927
4.99k
      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.99k
    } \
937
4.99k
  }
printMatrix_16
Line
Count
Source
909
1.30k
  { \
910
1.30k
    AArch64_add_cs_detail_1( \
911
1.30k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
1.30k
      EltSize); \
913
1.30k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
1.30k
\
915
1.30k
    printRegName(O, MCOperand_getReg(RegOp)); \
916
1.30k
    switch (EltSize) { \
917
0
    case 0: \
918
0
      break; \
919
0
    case 8: \
920
0
      SStream_concat0(O, ".b"); \
921
0
      break; \
922
1.30k
    case 16: \
923
1.30k
      SStream_concat0(O, ".h"); \
924
1.30k
      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.30k
    } \
937
1.30k
  }
printMatrix_0
Line
Count
Source
909
874
  { \
910
874
    AArch64_add_cs_detail_1( \
911
874
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
912
874
      EltSize); \
913
874
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
914
874
\
915
874
    printRegName(O, MCOperand_getReg(RegOp)); \
916
874
    switch (EltSize) { \
917
874
    case 0: \
918
874
      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
874
    } \
937
874
  }
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
8.49k
  { \
947
8.49k
    AArch64_add_cs_detail_1( \
948
8.49k
      MI, \
949
8.49k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
950
8.49k
      OpNum, IsVertical); \
951
8.49k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
952
8.49k
\
953
8.49k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
954
8.49k
                  AArch64_NoRegAltName); \
955
8.49k
\
956
8.49k
    unsigned buf_len = strlen(RegName) + 1; \
957
8.49k
    char *Base = cs_mem_calloc(1, buf_len); \
958
8.49k
    memcpy(Base, RegName, buf_len); \
959
8.49k
    char *Dot = strchr(Base, '.'); \
960
8.49k
    if (!Dot) { \
961
0
      SStream_concat0(O, RegName); \
962
0
      return; \
963
0
    } \
964
8.49k
    *Dot = '\0'; /* Split string */ \
965
8.49k
    char *Suffix = Dot + 1; \
966
8.49k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
967
8.49k
    SStream_concat1(O, '.'); \
968
8.49k
    SStream_concat0(O, Suffix); \
969
8.49k
    cs_mem_free(Base); \
970
8.49k
  }
printMatrixTileVector_0
Line
Count
Source
946
4.51k
  { \
947
4.51k
    AArch64_add_cs_detail_1( \
948
4.51k
      MI, \
949
4.51k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
950
4.51k
      OpNum, IsVertical); \
951
4.51k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
952
4.51k
\
953
4.51k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
954
4.51k
                  AArch64_NoRegAltName); \
955
4.51k
\
956
4.51k
    unsigned buf_len = strlen(RegName) + 1; \
957
4.51k
    char *Base = cs_mem_calloc(1, buf_len); \
958
4.51k
    memcpy(Base, RegName, buf_len); \
959
4.51k
    char *Dot = strchr(Base, '.'); \
960
4.51k
    if (!Dot) { \
961
0
      SStream_concat0(O, RegName); \
962
0
      return; \
963
0
    } \
964
4.51k
    *Dot = '\0'; /* Split string */ \
965
4.51k
    char *Suffix = Dot + 1; \
966
4.51k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
967
4.51k
    SStream_concat1(O, '.'); \
968
4.51k
    SStream_concat0(O, Suffix); \
969
4.51k
    cs_mem_free(Base); \
970
4.51k
  }
printMatrixTileVector_1
Line
Count
Source
946
3.98k
  { \
947
3.98k
    AArch64_add_cs_detail_1( \
948
3.98k
      MI, \
949
3.98k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
950
3.98k
      OpNum, IsVertical); \
951
3.98k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
952
3.98k
\
953
3.98k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
954
3.98k
                  AArch64_NoRegAltName); \
955
3.98k
\
956
3.98k
    unsigned buf_len = strlen(RegName) + 1; \
957
3.98k
    char *Base = cs_mem_calloc(1, buf_len); \
958
3.98k
    memcpy(Base, RegName, buf_len); \
959
3.98k
    char *Dot = strchr(Base, '.'); \
960
3.98k
    if (!Dot) { \
961
0
      SStream_concat0(O, RegName); \
962
0
      return; \
963
0
    } \
964
3.98k
    *Dot = '\0'; /* Split string */ \
965
3.98k
    char *Suffix = Dot + 1; \
966
3.98k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
967
3.98k
    SStream_concat1(O, '.'); \
968
3.98k
    SStream_concat0(O, Suffix); \
969
3.98k
    cs_mem_free(Base); \
970
3.98k
  }
971
DEFINE_printMatrixTileVector(0);
972
DEFINE_printMatrixTileVector(1);
973
974
void printMatrixTile(MCInst *MI, unsigned OpNum, SStream *O)
975
2.67k
{
976
2.67k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTile, OpNum);
977
2.67k
  MCOperand *RegOp = MCInst_getOperand(MI, (OpNum));
978
979
2.67k
  printRegName(O, MCOperand_getReg(RegOp));
980
2.67k
}
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
485k
{
995
485k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Operand, OpNo);
996
485k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
997
485k
  if (MCOperand_isReg(Op)) {
998
406k
    unsigned Reg = MCOperand_getReg(Op);
999
406k
    printRegName(O, Reg);
1000
406k
  } else if (MCOperand_isImm(Op)) {
1001
78.9k
    Op = MCInst_getOperand(MI, (OpNo));
1002
78.9k
    SStream_concat(O, "%s", markup("<imm:"));
1003
78.9k
    printInt64Bang(O, MCOperand_getImm(Op));
1004
78.9k
    SStream_concat0(O, markup(">"));
1005
78.9k
  } else {
1006
0
    printUInt64Bang(O, MCInst_getOpVal(MI, OpNo));
1007
0
  }
1008
485k
}
1009
1010
void printImm(MCInst *MI, unsigned OpNo, SStream *O)
1011
7.78k
{
1012
7.78k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Imm, OpNo);
1013
7.78k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1014
7.78k
  SStream_concat(O, "%s", markup("<imm:"));
1015
7.78k
  printInt64Bang(O, MCOperand_getImm(Op));
1016
7.78k
  SStream_concat0(O, markup(">"));
1017
7.78k
}
1018
1019
void printImmHex(MCInst *MI, unsigned OpNo, SStream *O)
1020
378
{
1021
378
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ImmHex, OpNo);
1022
378
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1023
378
  SStream_concat(O, "%s", markup("<imm:"));
1024
378
  printInt64Bang(O, MCOperand_getImm(Op));
1025
378
  SStream_concat0(O, markup(">"));
1026
378
}
1027
1028
#define DEFINE_printSImm(Size) \
1029
  void CONCAT(printSImm, Size)(MCInst * MI, unsigned OpNo, SStream *O) \
1030
2.63k
  { \
1031
2.63k
    AArch64_add_cs_detail_1( \
1032
2.63k
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1033
2.63k
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1034
2.63k
    if (Size == 8) { \
1035
469
      SStream_concat(O, "%s", markup("<imm:")); \
1036
469
      printInt32Bang(O, MCOperand_getImm(Op)); \
1037
469
      SStream_concat0(O, markup(">")); \
1038
2.16k
    } else if (Size == 16) { \
1039
2.16k
      SStream_concat(O, "%s", markup("<imm:")); \
1040
2.16k
      printInt32Bang(O, MCOperand_getImm(Op)); \
1041
2.16k
      SStream_concat0(O, markup(">")); \
1042
2.16k
    } 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.63k
  }
printSImm_16
Line
Count
Source
1030
2.16k
  { \
1031
2.16k
    AArch64_add_cs_detail_1( \
1032
2.16k
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1033
2.16k
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1034
2.16k
    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
2.16k
    } else if (Size == 16) { \
1039
2.16k
      SStream_concat(O, "%s", markup("<imm:")); \
1040
2.16k
      printInt32Bang(O, MCOperand_getImm(Op)); \
1041
2.16k
      SStream_concat0(O, markup(">")); \
1042
2.16k
    } 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.16k
  }
printSImm_8
Line
Count
Source
1030
469
  { \
1031
469
    AArch64_add_cs_detail_1( \
1032
469
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1033
469
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1034
469
    if (Size == 8) { \
1035
469
      SStream_concat(O, "%s", markup("<imm:")); \
1036
469
      printInt32Bang(O, MCOperand_getImm(Op)); \
1037
469
      SStream_concat0(O, markup(">")); \
1038
469
    } 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
469
  }
1048
DEFINE_printSImm(16);
1049
DEFINE_printSImm(8);
1050
1051
void printPostIncOperand(MCInst *MI, unsigned OpNo, unsigned Imm, SStream *O)
1052
12.0k
{
1053
12.0k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1054
12.0k
  if (MCOperand_isReg(Op)) {
1055
12.0k
    unsigned Reg = MCOperand_getReg(Op);
1056
12.0k
    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
12.0k
      printRegName(O, Reg);
1062
12.0k
  } else
1063
0
    CS_ASSERT_RET(0 &&
1064
12.0k
            "unknown operand kind in printPostIncOperand64");
1065
12.0k
}
1066
1067
void printVRegOperand(MCInst *MI, unsigned OpNo, SStream *O)
1068
87.5k
{
1069
87.5k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_VRegOperand, OpNo);
1070
87.5k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1071
1072
87.5k
  unsigned Reg = MCOperand_getReg(Op);
1073
87.5k
  printRegNameAlt(O, Reg, AArch64_vreg);
1074
87.5k
}
1075
1076
void printSysCROperand(MCInst *MI, unsigned OpNo, SStream *O)
1077
10.9k
{
1078
10.9k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SysCROperand, OpNo);
1079
10.9k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1080
1081
10.9k
  SStream_concat(O, "%s", "c");
1082
10.9k
  printUInt32(O, MCOperand_getImm(Op));
1083
10.9k
  SStream_concat1(O, '\0');
1084
10.9k
}
1085
1086
void printAddSubImm(MCInst *MI, unsigned OpNum, SStream *O)
1087
3.41k
{
1088
3.41k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AddSubImm, OpNum);
1089
3.41k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1090
3.41k
  if (MCOperand_isImm(MO)) {
1091
3.41k
    unsigned Val = (MCOperand_getImm(MO) & 0xfff);
1092
1093
3.41k
    unsigned Shift = AArch64_AM_getShiftValue(
1094
3.41k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))));
1095
3.41k
    SStream_concat(O, "%s", markup("<imm:"));
1096
3.41k
    printUInt32Bang(O, (Val));
1097
3.41k
    SStream_concat0(O, markup(">"));
1098
3.41k
    if (Shift != 0) {
1099
1.03k
      printShifter(MI, OpNum + 1, O);
1100
1.03k
    }
1101
3.41k
  } else {
1102
0
    printShifter(MI, OpNum + 1, O);
1103
0
  }
1104
3.41k
}
1105
1106
#define DEFINE_printLogicalImm(T) \
1107
  void CONCAT(printLogicalImm, T)(MCInst * MI, unsigned OpNum, \
1108
          SStream *O) \
1109
9.36k
  { \
1110
9.36k
    AArch64_add_cs_detail_1( \
1111
9.36k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
9.36k
      sizeof(T)); \
1113
9.36k
    uint64_t Val = \
1114
9.36k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
9.36k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
9.36k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
9.36k
             Val, 8 * sizeof(T)))); \
1118
9.36k
    SStream_concat0(O, markup(">")); \
1119
9.36k
  }
printLogicalImm_int64_t
Line
Count
Source
1109
3.65k
  { \
1110
3.65k
    AArch64_add_cs_detail_1( \
1111
3.65k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
3.65k
      sizeof(T)); \
1113
3.65k
    uint64_t Val = \
1114
3.65k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
3.65k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
3.65k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
3.65k
             Val, 8 * sizeof(T)))); \
1118
3.65k
    SStream_concat0(O, markup(">")); \
1119
3.65k
  }
printLogicalImm_int32_t
Line
Count
Source
1109
2.32k
  { \
1110
2.32k
    AArch64_add_cs_detail_1( \
1111
2.32k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
2.32k
      sizeof(T)); \
1113
2.32k
    uint64_t Val = \
1114
2.32k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
2.32k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
2.32k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
2.32k
             Val, 8 * sizeof(T)))); \
1118
2.32k
    SStream_concat0(O, markup(">")); \
1119
2.32k
  }
printLogicalImm_int8_t
Line
Count
Source
1109
2.44k
  { \
1110
2.44k
    AArch64_add_cs_detail_1( \
1111
2.44k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
2.44k
      sizeof(T)); \
1113
2.44k
    uint64_t Val = \
1114
2.44k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
2.44k
    SStream_concat(O, "%s", markup("<imm:")); \
1116
2.44k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
2.44k
             Val, 8 * sizeof(T)))); \
1118
2.44k
    SStream_concat0(O, markup(">")); \
1119
2.44k
  }
printLogicalImm_int16_t
Line
Count
Source
1109
943
  { \
1110
943
    AArch64_add_cs_detail_1( \
1111
943
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, \
1112
943
      sizeof(T)); \
1113
943
    uint64_t Val = \
1114
943
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1115
943
    SStream_concat(O, "%s", markup("<imm:")); \
1116
943
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1117
943
             Val, 8 * sizeof(T)))); \
1118
943
    SStream_concat0(O, markup(">")); \
1119
943
  }
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.4k
{
1127
14.4k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Shifter, OpNum);
1128
14.4k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1129
  // LSL #0 should not be printed.
1130
14.4k
  if (AArch64_AM_getShiftType(Val) == AArch64_AM_LSL &&
1131
9.23k
      AArch64_AM_getShiftValue(Val) == 0)
1132
1.85k
    return;
1133
12.5k
  SStream_concat(
1134
12.5k
    O, "%s%s%s%s#%d", ", ",
1135
12.5k
    AArch64_AM_getShiftExtendName(AArch64_AM_getShiftType(Val)),
1136
12.5k
    " ", markup("<imm:"), AArch64_AM_getShiftValue(Val));
1137
12.5k
  SStream_concat0(O, markup(">"));
1138
12.5k
}
1139
1140
void printShiftedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1141
6.64k
{
1142
6.64k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ShiftedRegister, OpNum);
1143
6.64k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1144
6.64k
  printShifter(MI, OpNum + 1, O);
1145
6.64k
}
1146
1147
void printExtendedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1148
1.91k
{
1149
1.91k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ExtendedRegister, OpNum);
1150
1.91k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1151
1.91k
  printArithExtend(MI, OpNum + 1, O);
1152
1.91k
}
1153
1154
void printArithExtend(MCInst *MI, unsigned OpNum, SStream *O)
1155
3.54k
{
1156
3.54k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ArithExtend, OpNum);
1157
3.54k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1158
3.54k
  AArch64_AM_ShiftExtendType ExtType = AArch64_AM_getArithExtendType(Val);
1159
3.54k
  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.54k
  if (ExtType == AArch64_AM_UXTW || ExtType == AArch64_AM_UXTX) {
1165
961
    unsigned Dest = MCOperand_getReg(MCInst_getOperand(MI, (0)));
1166
961
    unsigned Src1 = MCOperand_getReg(MCInst_getOperand(MI, (1)));
1167
961
    if (((Dest == AArch64_SP || Src1 == AArch64_SP) &&
1168
289
         ExtType == AArch64_AM_UXTX) ||
1169
885
        ((Dest == AArch64_WSP || Src1 == AArch64_WSP) &&
1170
150
         ExtType == AArch64_AM_UXTW)) {
1171
150
      if (ShiftVal != 0) {
1172
150
        SStream_concat(O, "%s%s", ", lsl ",
1173
150
                 markup("<imm:"));
1174
150
        printUInt32Bang(O, ShiftVal);
1175
150
        SStream_concat0(O, markup(">"));
1176
150
      }
1177
150
      return;
1178
150
    }
1179
961
  }
1180
3.39k
  SStream_concat(O, "%s", ", ");
1181
3.39k
  SStream_concat0(O, AArch64_AM_getShiftExtendName(ExtType));
1182
3.39k
  if (ShiftVal != 0) {
1183
2.72k
    SStream_concat(O, "%s%s#%d", " ", markup("<imm:"), ShiftVal);
1184
2.72k
    SStream_concat0(O, markup(">"));
1185
2.72k
  }
1186
3.39k
}
1187
1188
static void printMemExtendImpl(bool SignExtend, bool DoShift, unsigned Width,
1189
             char SrcRegKind, SStream *O, bool getUseMarkup)
1190
21.2k
{
1191
  // sxtw, sxtx, uxtw or lsl (== uxtx)
1192
21.2k
  bool IsLSL = !SignExtend && SrcRegKind == 'x';
1193
21.2k
  if (IsLSL)
1194
9.59k
    SStream_concat0(O, "lsl");
1195
11.6k
  else {
1196
11.6k
    SStream_concat(O, "%c%s", (SignExtend ? 's' : 'u'), "xt");
1197
11.6k
    SStream_concat1(O, SrcRegKind);
1198
11.6k
  }
1199
1200
21.2k
  if (DoShift || IsLSL) {
1201
16.8k
    SStream_concat0(O, " ");
1202
16.8k
    if (getUseMarkup)
1203
0
      SStream_concat0(O, "<imm:");
1204
16.8k
    unsigned ShiftAmount = DoShift ? Log2_32(Width / 8) : 0;
1205
16.8k
    SStream_concat(O, "%s%d", "#", ShiftAmount);
1206
16.8k
    if (getUseMarkup)
1207
0
      SStream_concat0(O, ">");
1208
16.8k
  }
1209
21.2k
}
1210
1211
void printMemExtend(MCInst *MI, unsigned OpNum, SStream *O, char SrcRegKind,
1212
        unsigned Width)
1213
2.99k
{
1214
2.99k
  bool SignExtend = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1215
2.99k
  bool DoShift = MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1)));
1216
2.99k
  printMemExtendImpl(SignExtend, DoShift, Width, SrcRegKind, O,
1217
2.99k
         getUseMarkup());
1218
2.99k
}
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
23.9k
  { \
1227
23.9k
    AArch64_add_cs_detail_4( \
1228
23.9k
      MI, \
1229
23.9k
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1230
23.9k
                SignExtend), \
1231
23.9k
               ExtWidth), \
1232
23.9k
              SrcRegKind), \
1233
23.9k
             Suffix), \
1234
23.9k
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1235
23.9k
      CHAR(Suffix)); \
1236
23.9k
    printOperand(MI, OpNum, O); \
1237
23.9k
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1238
13.3k
      SStream_concat1(O, '.'); \
1239
13.3k
      SStream_concat1(O, CHAR(Suffix)); \
1240
13.3k
      SStream_concat1(O, '\0'); \
1241
13.3k
    } else \
1242
23.9k
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1243
23.9k
              "Unsupported suffix size"); \
1244
23.9k
    bool DoShift = ExtWidth != 8; \
1245
23.9k
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1246
18.2k
      SStream_concat0(O, ", "); \
1247
18.2k
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1248
18.2k
             CHAR(SrcRegKind), O, \
1249
18.2k
             getUseMarkup()); \
1250
18.2k
    } \
1251
23.9k
  }
1252
1.16k
DEFINE_printRegWithShiftExtend(false, 8, x, d);
1253
695
DEFINE_printRegWithShiftExtend(true, 8, w, d);
1254
1.43k
DEFINE_printRegWithShiftExtend(false, 8, w, d);
1255
4.41k
DEFINE_printRegWithShiftExtend(false, 8, x, 0);
1256
492
DEFINE_printRegWithShiftExtend(true, 8, w, s);
1257
597
DEFINE_printRegWithShiftExtend(false, 8, w, s);
1258
947
DEFINE_printRegWithShiftExtend(false, 64, x, d);
1259
630
DEFINE_printRegWithShiftExtend(true, 64, w, d);
1260
944
DEFINE_printRegWithShiftExtend(false, 64, w, d);
1261
1.51k
DEFINE_printRegWithShiftExtend(false, 64, x, 0);
1262
206
DEFINE_printRegWithShiftExtend(true, 64, w, s);
1263
84
DEFINE_printRegWithShiftExtend(false, 64, w, s);
1264
388
DEFINE_printRegWithShiftExtend(false, 16, x, d);
1265
864
DEFINE_printRegWithShiftExtend(true, 16, w, d);
1266
1.03k
DEFINE_printRegWithShiftExtend(false, 16, w, d);
1267
2.85k
DEFINE_printRegWithShiftExtend(false, 16, x, 0);
1268
184
DEFINE_printRegWithShiftExtend(true, 16, w, s);
1269
189
DEFINE_printRegWithShiftExtend(false, 16, w, s);
1270
1.02k
DEFINE_printRegWithShiftExtend(false, 32, x, d);
1271
253
DEFINE_printRegWithShiftExtend(true, 32, w, d);
1272
1.50k
DEFINE_printRegWithShiftExtend(false, 32, w, d);
1273
1.27k
DEFINE_printRegWithShiftExtend(false, 32, x, 0);
1274
334
DEFINE_printRegWithShiftExtend(true, 32, w, s);
1275
153
DEFINE_printRegWithShiftExtend(false, 32, w, s);
1276
65
DEFINE_printRegWithShiftExtend(false, 8, x, s);
1277
111
DEFINE_printRegWithShiftExtend(false, 16, x, s);
1278
37
DEFINE_printRegWithShiftExtend(false, 32, x, s);
1279
41
DEFINE_printRegWithShiftExtend(false, 64, x, s);
1280
456
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
13.7k
  { \
1286
13.7k
    AArch64_add_cs_detail_1( \
1287
13.7k
      MI, \
1288
13.7k
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
13.7k
      OpNum, EltSize); \
1290
13.7k
    unsigned Reg = \
1291
13.7k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
13.7k
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
13.7k
      CS_ASSERT_RET( \
1294
13.7k
        0 && \
1295
13.7k
        "Unsupported predicate-as-counter register"); \
1296
13.7k
    SStream_concat(O, "%s", "pn"); \
1297
13.7k
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
13.7k
    switch (EltSize) { \
1299
11.8k
    case 0: \
1300
11.8k
      break; \
1301
600
    case 8: \
1302
600
      SStream_concat0(O, ".b"); \
1303
600
      break; \
1304
452
    case 16: \
1305
452
      SStream_concat0(O, ".h"); \
1306
452
      break; \
1307
202
    case 32: \
1308
202
      SStream_concat0(O, ".s"); \
1309
202
      break; \
1310
636
    case 64: \
1311
636
      SStream_concat0(O, ".d"); \
1312
636
      break; \
1313
0
    default: \
1314
0
      CS_ASSERT_RET(0 && "Unsupported element size"); \
1315
13.7k
    } \
1316
13.7k
  }
printPredicateAsCounter_8
Line
Count
Source
1285
600
  { \
1286
600
    AArch64_add_cs_detail_1( \
1287
600
      MI, \
1288
600
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
600
      OpNum, EltSize); \
1290
600
    unsigned Reg = \
1291
600
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
600
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
600
      CS_ASSERT_RET( \
1294
600
        0 && \
1295
600
        "Unsupported predicate-as-counter register"); \
1296
600
    SStream_concat(O, "%s", "pn"); \
1297
600
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
600
    switch (EltSize) { \
1299
0
    case 0: \
1300
0
      break; \
1301
600
    case 8: \
1302
600
      SStream_concat0(O, ".b"); \
1303
600
      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
600
    } \
1316
600
  }
printPredicateAsCounter_64
Line
Count
Source
1285
636
  { \
1286
636
    AArch64_add_cs_detail_1( \
1287
636
      MI, \
1288
636
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
636
      OpNum, EltSize); \
1290
636
    unsigned Reg = \
1291
636
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
636
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
636
      CS_ASSERT_RET( \
1294
636
        0 && \
1295
636
        "Unsupported predicate-as-counter register"); \
1296
636
    SStream_concat(O, "%s", "pn"); \
1297
636
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
636
    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
636
    case 64: \
1311
636
      SStream_concat0(O, ".d"); \
1312
636
      break; \
1313
0
    default: \
1314
0
      CS_ASSERT_RET(0 && "Unsupported element size"); \
1315
636
    } \
1316
636
  }
printPredicateAsCounter_16
Line
Count
Source
1285
452
  { \
1286
452
    AArch64_add_cs_detail_1( \
1287
452
      MI, \
1288
452
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
452
      OpNum, EltSize); \
1290
452
    unsigned Reg = \
1291
452
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
452
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
452
      CS_ASSERT_RET( \
1294
452
        0 && \
1295
452
        "Unsupported predicate-as-counter register"); \
1296
452
    SStream_concat(O, "%s", "pn"); \
1297
452
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
452
    switch (EltSize) { \
1299
0
    case 0: \
1300
0
      break; \
1301
0
    case 8: \
1302
0
      SStream_concat0(O, ".b"); \
1303
0
      break; \
1304
452
    case 16: \
1305
452
      SStream_concat0(O, ".h"); \
1306
452
      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
452
    } \
1316
452
  }
printPredicateAsCounter_32
Line
Count
Source
1285
202
  { \
1286
202
    AArch64_add_cs_detail_1( \
1287
202
      MI, \
1288
202
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
202
      OpNum, EltSize); \
1290
202
    unsigned Reg = \
1291
202
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
202
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
202
      CS_ASSERT_RET( \
1294
202
        0 && \
1295
202
        "Unsupported predicate-as-counter register"); \
1296
202
    SStream_concat(O, "%s", "pn"); \
1297
202
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
202
    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
202
    case 32: \
1308
202
      SStream_concat0(O, ".s"); \
1309
202
      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
202
    } \
1316
202
  }
printPredicateAsCounter_0
Line
Count
Source
1285
11.8k
  { \
1286
11.8k
    AArch64_add_cs_detail_1( \
1287
11.8k
      MI, \
1288
11.8k
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1289
11.8k
      OpNum, EltSize); \
1290
11.8k
    unsigned Reg = \
1291
11.8k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1292
11.8k
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1293
11.8k
      CS_ASSERT_RET( \
1294
11.8k
        0 && \
1295
11.8k
        "Unsupported predicate-as-counter register"); \
1296
11.8k
    SStream_concat(O, "%s", "pn"); \
1297
11.8k
    printUInt32(O, (Reg - AArch64_PN0)); \
1298
11.8k
    switch (EltSize) { \
1299
11.8k
    case 0: \
1300
11.8k
      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
11.8k
    } \
1316
11.8k
  }
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
4.26k
{
1325
4.26k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_CondCode, OpNum);
1326
4.26k
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(
1327
4.26k
    MCInst_getOperand(MI, (OpNum)));
1328
4.26k
  SStream_concat0(O, AArch64CC_getCondCodeName(CC));
1329
4.26k
}
1330
1331
void printInverseCondCode(MCInst *MI, unsigned OpNum, SStream *O)
1332
495
{
1333
495
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_InverseCondCode, OpNum);
1334
495
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(
1335
495
    MCInst_getOperand(MI, (OpNum)));
1336
495
  SStream_concat0(O, AArch64CC_getCondCodeName(
1337
495
           AArch64CC_getInvertedCondCode(CC)));
1338
495
}
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
23.6k
  { \
1353
23.6k
    AArch64_add_cs_detail_1( \
1354
23.6k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
23.6k
      Scale); \
1356
23.6k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
23.6k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
23.6k
            MCInst_getOperand(MI, (OpNum)))); \
1359
23.6k
    SStream_concat0(O, markup(">")); \
1360
23.6k
  }
printImmScale_8
Line
Count
Source
1352
6.67k
  { \
1353
6.67k
    AArch64_add_cs_detail_1( \
1354
6.67k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
6.67k
      Scale); \
1356
6.67k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
6.67k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
6.67k
            MCInst_getOperand(MI, (OpNum)))); \
1359
6.67k
    SStream_concat0(O, markup(">")); \
1360
6.67k
  }
printImmScale_2
Line
Count
Source
1352
1.55k
  { \
1353
1.55k
    AArch64_add_cs_detail_1( \
1354
1.55k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
1.55k
      Scale); \
1356
1.55k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
1.55k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
1.55k
            MCInst_getOperand(MI, (OpNum)))); \
1359
1.55k
    SStream_concat0(O, markup(">")); \
1360
1.55k
  }
printImmScale_4
Line
Count
Source
1352
11.0k
  { \
1353
11.0k
    AArch64_add_cs_detail_1( \
1354
11.0k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
11.0k
      Scale); \
1356
11.0k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
11.0k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
11.0k
            MCInst_getOperand(MI, (OpNum)))); \
1359
11.0k
    SStream_concat0(O, markup(">")); \
1360
11.0k
  }
printImmScale_16
Line
Count
Source
1352
4.09k
  { \
1353
4.09k
    AArch64_add_cs_detail_1( \
1354
4.09k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
4.09k
      Scale); \
1356
4.09k
    SStream_concat(O, "%s", markup("<imm:")); \
1357
4.09k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
4.09k
            MCInst_getOperand(MI, (OpNum)))); \
1359
4.09k
    SStream_concat0(O, markup(">")); \
1360
4.09k
  }
printImmScale_32
Line
Count
Source
1352
80
  { \
1353
80
    AArch64_add_cs_detail_1( \
1354
80
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
80
      Scale); \
1356
80
    SStream_concat(O, "%s", markup("<imm:")); \
1357
80
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
80
            MCInst_getOperand(MI, (OpNum)))); \
1359
80
    SStream_concat0(O, markup(">")); \
1360
80
  }
printImmScale_3
Line
Count
Source
1352
202
  { \
1353
202
    AArch64_add_cs_detail_1( \
1354
202
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1355
202
      Scale); \
1356
202
    SStream_concat(O, "%s", markup("<imm:")); \
1357
202
    printInt32Bang(O, Scale *MCOperand_getImm( \
1358
202
            MCInst_getOperand(MI, (OpNum)))); \
1359
202
    SStream_concat0(O, markup(">")); \
1360
202
  }
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.75k
  { \
1372
6.75k
    AArch64_add_cs_detail_2( \
1373
6.75k
      MI, \
1374
6.75k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1375
6.75k
             Offset), \
1376
6.75k
      OpNum, Scale, Offset); \
1377
6.75k
    unsigned FirstImm = \
1378
6.75k
      Scale * \
1379
6.75k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1380
6.75k
    printUInt32(O, (FirstImm)); \
1381
6.75k
    SStream_concat(O, "%s", ":"); \
1382
6.75k
    printUInt32(O, (FirstImm + Offset)); \
1383
6.75k
    SStream_concat1(O, '\0'); \
1384
6.75k
  }
printImmRangeScale_2_1
Line
Count
Source
1371
3.11k
  { \
1372
3.11k
    AArch64_add_cs_detail_2( \
1373
3.11k
      MI, \
1374
3.11k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1375
3.11k
             Offset), \
1376
3.11k
      OpNum, Scale, Offset); \
1377
3.11k
    unsigned FirstImm = \
1378
3.11k
      Scale * \
1379
3.11k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1380
3.11k
    printUInt32(O, (FirstImm)); \
1381
3.11k
    SStream_concat(O, "%s", ":"); \
1382
3.11k
    printUInt32(O, (FirstImm + Offset)); \
1383
3.11k
    SStream_concat1(O, '\0'); \
1384
3.11k
  }
printImmRangeScale_4_3
Line
Count
Source
1371
3.63k
  { \
1372
3.63k
    AArch64_add_cs_detail_2( \
1373
3.63k
      MI, \
1374
3.63k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1375
3.63k
             Offset), \
1376
3.63k
      OpNum, Scale, Offset); \
1377
3.63k
    unsigned FirstImm = \
1378
3.63k
      Scale * \
1379
3.63k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1380
3.63k
    printUInt32(O, (FirstImm)); \
1381
3.63k
    SStream_concat(O, "%s", ":"); \
1382
3.63k
    printUInt32(O, (FirstImm + Offset)); \
1383
3.63k
    SStream_concat1(O, '\0'); \
1384
3.63k
  }
1385
DEFINE_printImmRangeScale(2, 1);
1386
DEFINE_printImmRangeScale(4, 3);
1387
1388
void printUImm12Offset(MCInst *MI, unsigned OpNum, unsigned Scale, SStream *O)
1389
6.22k
{
1390
6.22k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1391
6.22k
  if (MCOperand_isImm(MO)) {
1392
6.22k
    SStream_concat(O, "%s", markup("<imm:"));
1393
6.22k
    printUInt32Bang(O, (MCOperand_getImm(MO) * Scale));
1394
6.22k
    SStream_concat0(O, markup(">"));
1395
6.22k
  } else {
1396
0
    printUInt64Bang(O, MCOperand_getImm(MO));
1397
0
  }
1398
6.22k
}
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
874
{
1418
874
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_RPRFMOperand, OpNum);
1419
874
  unsigned prfop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1420
874
  const AArch64PRFM_PRFM *PRFM =
1421
874
    AArch64RPRFM_lookupRPRFMByEncoding(prfop);
1422
874
  if (PRFM) {
1423
632
    SStream_concat0(O, PRFM->Name);
1424
632
    return;
1425
632
  }
1426
1427
242
  printUInt32Bang(O, (prfop));
1428
242
  SStream_concat1(O, '\0');
1429
242
}
1430
1431
#define DEFINE_printPrefetchOp(IsSVEPrefetch) \
1432
  void CONCAT(printPrefetchOp, \
1433
        IsSVEPrefetch)(MCInst * MI, unsigned OpNum, SStream *O) \
1434
7.99k
  { \
1435
7.99k
    AArch64_add_cs_detail_1(MI, \
1436
7.99k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1437
7.99k
                 IsSVEPrefetch), \
1438
7.99k
          OpNum, IsSVEPrefetch); \
1439
7.99k
    unsigned prfop = \
1440
7.99k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1441
7.99k
    if (IsSVEPrefetch) { \
1442
6.42k
      const AArch64SVEPRFM_SVEPRFM *PRFM = \
1443
6.42k
        AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \
1444
6.42k
      if (PRFM) { \
1445
5.53k
        SStream_concat0(O, PRFM->Name); \
1446
5.53k
        return; \
1447
5.53k
      } \
1448
6.42k
    } else { \
1449
1.56k
      const AArch64PRFM_PRFM *PRFM = \
1450
1.56k
        AArch64PRFM_lookupPRFMByEncoding(prfop); \
1451
1.56k
      if (PRFM && \
1452
1.56k
          AArch64_testFeatureList(MI->csh->mode, \
1453
942
                PRFM->FeaturesRequired)) { \
1454
942
        SStream_concat0(O, PRFM->Name); \
1455
942
        return; \
1456
942
      } \
1457
1.56k
    } \
1458
7.99k
\
1459
7.99k
    SStream_concat(O, "%s", markup("<imm:")); \
1460
1.52k
    printUInt32Bang(O, (prfop)); \
1461
1.52k
    SStream_concat0(O, markup(">")); \
1462
1.52k
  }
printPrefetchOp_0
Line
Count
Source
1434
1.56k
  { \
1435
1.56k
    AArch64_add_cs_detail_1(MI, \
1436
1.56k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1437
1.56k
                 IsSVEPrefetch), \
1438
1.56k
          OpNum, IsSVEPrefetch); \
1439
1.56k
    unsigned prfop = \
1440
1.56k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1441
1.56k
    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.56k
    } else { \
1449
1.56k
      const AArch64PRFM_PRFM *PRFM = \
1450
1.56k
        AArch64PRFM_lookupPRFMByEncoding(prfop); \
1451
1.56k
      if (PRFM && \
1452
1.56k
          AArch64_testFeatureList(MI->csh->mode, \
1453
942
                PRFM->FeaturesRequired)) { \
1454
942
        SStream_concat0(O, PRFM->Name); \
1455
942
        return; \
1456
942
      } \
1457
1.56k
    } \
1458
1.56k
\
1459
1.56k
    SStream_concat(O, "%s", markup("<imm:")); \
1460
624
    printUInt32Bang(O, (prfop)); \
1461
624
    SStream_concat0(O, markup(">")); \
1462
624
  }
printPrefetchOp_1
Line
Count
Source
1434
6.42k
  { \
1435
6.42k
    AArch64_add_cs_detail_1(MI, \
1436
6.42k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1437
6.42k
                 IsSVEPrefetch), \
1438
6.42k
          OpNum, IsSVEPrefetch); \
1439
6.42k
    unsigned prfop = \
1440
6.42k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1441
6.42k
    if (IsSVEPrefetch) { \
1442
6.42k
      const AArch64SVEPRFM_SVEPRFM *PRFM = \
1443
6.42k
        AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \
1444
6.42k
      if (PRFM) { \
1445
5.53k
        SStream_concat0(O, PRFM->Name); \
1446
5.53k
        return; \
1447
5.53k
      } \
1448
6.42k
    } 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
6.42k
\
1459
6.42k
    SStream_concat(O, "%s", markup("<imm:")); \
1460
897
    printUInt32Bang(O, (prfop)); \
1461
897
    SStream_concat0(O, markup(">")); \
1462
897
  }
1463
DEFINE_printPrefetchOp(false);
1464
DEFINE_printPrefetchOp(true);
1465
1466
void printPSBHintOp(MCInst *MI, unsigned OpNum, SStream *O)
1467
407
{
1468
407
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_PSBHintOp, OpNum);
1469
407
  unsigned psbhintop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1470
407
  const AArch64PSBHint_PSB *PSB =
1471
407
    AArch64PSBHint_lookupPSBByEncoding(psbhintop);
1472
407
  if (PSB)
1473
407
    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
407
}
1481
1482
void printBTIHintOp(MCInst *MI, unsigned OpNum, SStream *O)
1483
530
{
1484
530
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BTIHintOp, OpNum);
1485
530
  unsigned btihintop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))) ^
1486
530
           32;
1487
530
  const AArch64BTIHint_BTI *BTI =
1488
530
    AArch64BTIHint_lookupBTIByEncoding(btihintop);
1489
530
  if (BTI)
1490
530
    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
530
}
1497
1498
static void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1499
604
{
1500
604
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_FPImmOperand, OpNum);
1501
604
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1502
604
  float FPImm = MCOperand_isDFPImm(MO) ?
1503
0
            BitsToDouble(MCOperand_getImm(MO)) :
1504
604
            AArch64_AM_getFPImmFloat(MCOperand_getImm(MO));
1505
1506
  // 8 decimal places are enough to perfectly represent permitted floats.
1507
604
  SStream_concat(O, "%s", markup("<imm:"));
1508
604
  SStream_concat(O, "#%.8f", FPImm);
1509
604
  SStream_concat0(O, markup(">"));
1510
604
}
1511
1512
static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride /* = 1 */)
1513
162k
{
1514
430k
  while (Stride--) {
1515
267k
    switch (Reg) {
1516
0
    default:
1517
0
      CS_ASSERT_RET_VAL(0 && "Vector register expected!", 0);
1518
5.24k
    case AArch64_Q0:
1519
5.24k
      Reg = AArch64_Q1;
1520
5.24k
      break;
1521
4.70k
    case AArch64_Q1:
1522
4.70k
      Reg = AArch64_Q2;
1523
4.70k
      break;
1524
2.85k
    case AArch64_Q2:
1525
2.85k
      Reg = AArch64_Q3;
1526
2.85k
      break;
1527
2.06k
    case AArch64_Q3:
1528
2.06k
      Reg = AArch64_Q4;
1529
2.06k
      break;
1530
1.71k
    case AArch64_Q4:
1531
1.71k
      Reg = AArch64_Q5;
1532
1.71k
      break;
1533
1.45k
    case AArch64_Q5:
1534
1.45k
      Reg = AArch64_Q6;
1535
1.45k
      break;
1536
891
    case AArch64_Q6:
1537
891
      Reg = AArch64_Q7;
1538
891
      break;
1539
2.01k
    case AArch64_Q7:
1540
2.01k
      Reg = AArch64_Q8;
1541
2.01k
      break;
1542
1.81k
    case AArch64_Q8:
1543
1.81k
      Reg = AArch64_Q9;
1544
1.81k
      break;
1545
1.57k
    case AArch64_Q9:
1546
1.57k
      Reg = AArch64_Q10;
1547
1.57k
      break;
1548
3.56k
    case AArch64_Q10:
1549
3.56k
      Reg = AArch64_Q11;
1550
3.56k
      break;
1551
3.71k
    case AArch64_Q11:
1552
3.71k
      Reg = AArch64_Q12;
1553
3.71k
      break;
1554
4.27k
    case AArch64_Q12:
1555
4.27k
      Reg = AArch64_Q13;
1556
4.27k
      break;
1557
3.03k
    case AArch64_Q13:
1558
3.03k
      Reg = AArch64_Q14;
1559
3.03k
      break;
1560
2.11k
    case AArch64_Q14:
1561
2.11k
      Reg = AArch64_Q15;
1562
2.11k
      break;
1563
1.48k
    case AArch64_Q15:
1564
1.48k
      Reg = AArch64_Q16;
1565
1.48k
      break;
1566
1.96k
    case AArch64_Q16:
1567
1.96k
      Reg = AArch64_Q17;
1568
1.96k
      break;
1569
2.18k
    case AArch64_Q17:
1570
2.18k
      Reg = AArch64_Q18;
1571
2.18k
      break;
1572
2.74k
    case AArch64_Q18:
1573
2.74k
      Reg = AArch64_Q19;
1574
2.74k
      break;
1575
3.21k
    case AArch64_Q19:
1576
3.21k
      Reg = AArch64_Q20;
1577
3.21k
      break;
1578
5.17k
    case AArch64_Q20:
1579
5.17k
      Reg = AArch64_Q21;
1580
5.17k
      break;
1581
3.19k
    case AArch64_Q21:
1582
3.19k
      Reg = AArch64_Q22;
1583
3.19k
      break;
1584
2.86k
    case AArch64_Q22:
1585
2.86k
      Reg = AArch64_Q23;
1586
2.86k
      break;
1587
2.41k
    case AArch64_Q23:
1588
2.41k
      Reg = AArch64_Q24;
1589
2.41k
      break;
1590
3.01k
    case AArch64_Q24:
1591
3.01k
      Reg = AArch64_Q25;
1592
3.01k
      break;
1593
2.67k
    case AArch64_Q25:
1594
2.67k
      Reg = AArch64_Q26;
1595
2.67k
      break;
1596
2.27k
    case AArch64_Q26:
1597
2.27k
      Reg = AArch64_Q27;
1598
2.27k
      break;
1599
1.36k
    case AArch64_Q27:
1600
1.36k
      Reg = AArch64_Q28;
1601
1.36k
      break;
1602
1.27k
    case AArch64_Q28:
1603
1.27k
      Reg = AArch64_Q29;
1604
1.27k
      break;
1605
1.00k
    case AArch64_Q29:
1606
1.00k
      Reg = AArch64_Q30;
1607
1.00k
      break;
1608
732
    case AArch64_Q30:
1609
732
      Reg = AArch64_Q31;
1610
732
      break;
1611
    // Vector lists can wrap around.
1612
2.16k
    case AArch64_Q31:
1613
2.16k
      Reg = AArch64_Q0;
1614
2.16k
      break;
1615
17.7k
    case AArch64_Z0:
1616
17.7k
      Reg = AArch64_Z1;
1617
17.7k
      break;
1618
13.0k
    case AArch64_Z1:
1619
13.0k
      Reg = AArch64_Z2;
1620
13.0k
      break;
1621
13.3k
    case AArch64_Z2:
1622
13.3k
      Reg = AArch64_Z3;
1623
13.3k
      break;
1624
4.38k
    case AArch64_Z3:
1625
4.38k
      Reg = AArch64_Z4;
1626
4.38k
      break;
1627
11.1k
    case AArch64_Z4:
1628
11.1k
      Reg = AArch64_Z5;
1629
11.1k
      break;
1630
8.05k
    case AArch64_Z5:
1631
8.05k
      Reg = AArch64_Z6;
1632
8.05k
      break;
1633
7.90k
    case AArch64_Z6:
1634
7.90k
      Reg = AArch64_Z7;
1635
7.90k
      break;
1636
3.45k
    case AArch64_Z7:
1637
3.45k
      Reg = AArch64_Z8;
1638
3.45k
      break;
1639
7.84k
    case AArch64_Z8:
1640
7.84k
      Reg = AArch64_Z9;
1641
7.84k
      break;
1642
6.10k
    case AArch64_Z9:
1643
6.10k
      Reg = AArch64_Z10;
1644
6.10k
      break;
1645
6.48k
    case AArch64_Z10:
1646
6.48k
      Reg = AArch64_Z11;
1647
6.48k
      break;
1648
2.97k
    case AArch64_Z11:
1649
2.97k
      Reg = AArch64_Z12;
1650
2.97k
      break;
1651
4.17k
    case AArch64_Z12:
1652
4.17k
      Reg = AArch64_Z13;
1653
4.17k
      break;
1654
4.01k
    case AArch64_Z13:
1655
4.01k
      Reg = AArch64_Z14;
1656
4.01k
      break;
1657
5.52k
    case AArch64_Z14:
1658
5.52k
      Reg = AArch64_Z15;
1659
5.52k
      break;
1660
3.59k
    case AArch64_Z15:
1661
3.59k
      Reg = AArch64_Z16;
1662
3.59k
      break;
1663
3.66k
    case AArch64_Z16:
1664
3.66k
      Reg = AArch64_Z17;
1665
3.66k
      break;
1666
1.96k
    case AArch64_Z17:
1667
1.96k
      Reg = AArch64_Z18;
1668
1.96k
      break;
1669
1.82k
    case AArch64_Z18:
1670
1.82k
      Reg = AArch64_Z19;
1671
1.82k
      break;
1672
2.49k
    case AArch64_Z19:
1673
2.49k
      Reg = AArch64_Z20;
1674
2.49k
      break;
1675
5.25k
    case AArch64_Z20:
1676
5.25k
      Reg = AArch64_Z21;
1677
5.25k
      break;
1678
4.60k
    case AArch64_Z21:
1679
4.60k
      Reg = AArch64_Z22;
1680
4.60k
      break;
1681
4.90k
    case AArch64_Z22:
1682
4.90k
      Reg = AArch64_Z23;
1683
4.90k
      break;
1684
2.72k
    case AArch64_Z23:
1685
2.72k
      Reg = AArch64_Z24;
1686
2.72k
      break;
1687
5.52k
    case AArch64_Z24:
1688
5.52k
      Reg = AArch64_Z25;
1689
5.52k
      break;
1690
4.15k
    case AArch64_Z25:
1691
4.15k
      Reg = AArch64_Z26;
1692
4.15k
      break;
1693
4.31k
    case AArch64_Z26:
1694
4.31k
      Reg = AArch64_Z27;
1695
4.31k
      break;
1696
2.99k
    case AArch64_Z27:
1697
2.99k
      Reg = AArch64_Z28;
1698
2.99k
      break;
1699
3.63k
    case AArch64_Z28:
1700
3.63k
      Reg = AArch64_Z29;
1701
3.63k
      break;
1702
3.21k
    case AArch64_Z29:
1703
3.21k
      Reg = AArch64_Z30;
1704
3.21k
      break;
1705
4.02k
    case AArch64_Z30:
1706
4.02k
      Reg = AArch64_Z31;
1707
4.02k
      break;
1708
    // Vector lists can wrap around.
1709
3.87k
    case AArch64_Z31:
1710
3.87k
      Reg = AArch64_Z0;
1711
3.87k
      break;
1712
1.02k
    case AArch64_P0:
1713
1.02k
      Reg = AArch64_P1;
1714
1.02k
      break;
1715
452
    case AArch64_P1:
1716
452
      Reg = AArch64_P2;
1717
452
      break;
1718
622
    case AArch64_P2:
1719
622
      Reg = AArch64_P3;
1720
622
      break;
1721
446
    case AArch64_P3:
1722
446
      Reg = AArch64_P4;
1723
446
      break;
1724
414
    case AArch64_P4:
1725
414
      Reg = AArch64_P5;
1726
414
      break;
1727
588
    case AArch64_P5:
1728
588
      Reg = AArch64_P6;
1729
588
      break;
1730
1.08k
    case AArch64_P6:
1731
1.08k
      Reg = AArch64_P7;
1732
1.08k
      break;
1733
200
    case AArch64_P7:
1734
200
      Reg = AArch64_P8;
1735
200
      break;
1736
148
    case AArch64_P8:
1737
148
      Reg = AArch64_P9;
1738
148
      break;
1739
166
    case AArch64_P9:
1740
166
      Reg = AArch64_P10;
1741
166
      break;
1742
172
    case AArch64_P10:
1743
172
      Reg = AArch64_P11;
1744
172
      break;
1745
660
    case AArch64_P11:
1746
660
      Reg = AArch64_P12;
1747
660
      break;
1748
168
    case AArch64_P12:
1749
168
      Reg = AArch64_P13;
1750
168
      break;
1751
1.28k
    case AArch64_P13:
1752
1.28k
      Reg = AArch64_P14;
1753
1.28k
      break;
1754
142
    case AArch64_P14:
1755
142
      Reg = AArch64_P15;
1756
142
      break;
1757
    // Vector lists can wrap around.
1758
524
    case AArch64_P15:
1759
524
      Reg = AArch64_P0;
1760
524
      break;
1761
267k
    }
1762
267k
  }
1763
162k
  return Reg;
1764
162k
}
1765
1766
#define DEFINE_printGPRSeqPairsClassOperand(size) \
1767
  void CONCAT(printGPRSeqPairsClassOperand, \
1768
        size)(MCInst * MI, unsigned OpNum, SStream *O) \
1769
3.56k
  { \
1770
3.56k
    AArch64_add_cs_detail_1( \
1771
3.56k
      MI, \
1772
3.56k
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1773
3.56k
             size), \
1774
3.56k
      OpNum, size); \
1775
3.56k
    CS_ASSERT_RET((size == 64 || size == 32) && \
1776
3.56k
            "Template parameter must be either 32 or 64"); \
1777
3.56k
    unsigned Reg = \
1778
3.56k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1779
3.56k
\
1780
3.56k
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1781
3.56k
                 AArch64_sube64; \
1782
3.56k
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1783
3.56k
                 AArch64_subo64; \
1784
3.56k
\
1785
3.56k
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1786
3.56k
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1787
3.56k
    printRegName(O, Even); \
1788
3.56k
    SStream_concat0(O, ", "); \
1789
3.56k
    printRegName(O, Odd); \
1790
3.56k
  }
printGPRSeqPairsClassOperand_32
Line
Count
Source
1769
138
  { \
1770
138
    AArch64_add_cs_detail_1( \
1771
138
      MI, \
1772
138
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1773
138
             size), \
1774
138
      OpNum, size); \
1775
138
    CS_ASSERT_RET((size == 64 || size == 32) && \
1776
138
            "Template parameter must be either 32 or 64"); \
1777
138
    unsigned Reg = \
1778
138
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1779
138
\
1780
138
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1781
138
                 AArch64_sube64; \
1782
138
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1783
138
                 AArch64_subo64; \
1784
138
\
1785
138
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1786
138
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1787
138
    printRegName(O, Even); \
1788
138
    SStream_concat0(O, ", "); \
1789
138
    printRegName(O, Odd); \
1790
138
  }
printGPRSeqPairsClassOperand_64
Line
Count
Source
1769
3.42k
  { \
1770
3.42k
    AArch64_add_cs_detail_1( \
1771
3.42k
      MI, \
1772
3.42k
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1773
3.42k
             size), \
1774
3.42k
      OpNum, size); \
1775
3.42k
    CS_ASSERT_RET((size == 64 || size == 32) && \
1776
3.42k
            "Template parameter must be either 32 or 64"); \
1777
3.42k
    unsigned Reg = \
1778
3.42k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1779
3.42k
\
1780
3.42k
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1781
3.42k
                 AArch64_sube64; \
1782
3.42k
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1783
3.42k
                 AArch64_subo64; \
1784
3.42k
\
1785
3.42k
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1786
3.42k
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1787
3.42k
    printRegName(O, Even); \
1788
3.42k
    SStream_concat0(O, ", "); \
1789
3.42k
    printRegName(O, Odd); \
1790
3.42k
  }
1791
DEFINE_printGPRSeqPairsClassOperand(32);
1792
DEFINE_printGPRSeqPairsClassOperand(64);
1793
1794
#define DEFINE_printMatrixIndex(Scale) \
1795
  void CONCAT(printMatrixIndex, Scale)(MCInst * MI, unsigned OpNum, \
1796
               SStream *O) \
1797
12.4k
  { \
1798
12.4k
    AArch64_add_cs_detail_1( \
1799
12.4k
      MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1800
12.4k
      OpNum, Scale); \
1801
12.4k
    printInt64(O, Scale *MCOperand_getImm( \
1802
12.4k
              MCInst_getOperand(MI, (OpNum)))); \
1803
12.4k
  }
printMatrixIndex_8
Line
Count
Source
1797
576
  { \
1798
576
    AArch64_add_cs_detail_1( \
1799
576
      MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1800
576
      OpNum, Scale); \
1801
576
    printInt64(O, Scale *MCOperand_getImm( \
1802
576
              MCInst_getOperand(MI, (OpNum)))); \
1803
576
  }
Unexecuted instantiation: printMatrixIndex_0
printMatrixIndex_1
Line
Count
Source
1797
11.8k
  { \
1798
11.8k
    AArch64_add_cs_detail_1( \
1799
11.8k
      MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1800
11.8k
      OpNum, Scale); \
1801
11.8k
    printInt64(O, Scale *MCOperand_getImm( \
1802
11.8k
              MCInst_getOperand(MI, (OpNum)))); \
1803
11.8k
  }
1804
DEFINE_printMatrixIndex(8);
1805
DEFINE_printMatrixIndex(0);
1806
DEFINE_printMatrixIndex(1);
1807
1808
void printMatrixTileList(MCInst *MI, unsigned OpNum, SStream *O)
1809
491
{
1810
491
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTileList, OpNum);
1811
491
  unsigned MaxRegs = 8;
1812
491
  unsigned RegMask = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1813
1814
491
  unsigned NumRegs = 0;
1815
4.41k
  for (unsigned I = 0; I < MaxRegs; ++I)
1816
3.92k
    if ((RegMask & (1 << I)) != 0)
1817
1.62k
      ++NumRegs;
1818
1819
491
  SStream_concat0(O, "{");
1820
491
  unsigned Printed = 0;
1821
4.41k
  for (unsigned I = 0; I < MaxRegs; ++I) {
1822
3.92k
    unsigned Reg = RegMask & (1 << I);
1823
3.92k
    if (Reg == 0)
1824
2.30k
      continue;
1825
1.62k
    printRegName(O, AArch64_ZAD0 + I);
1826
1.62k
    if (Printed + 1 != NumRegs)
1827
1.14k
      SStream_concat0(O, ", ");
1828
1.62k
    ++Printed;
1829
1.62k
  }
1830
491
  SStream_concat0(O, "}");
1831
491
}
1832
1833
void printVectorList(MCInst *MI, unsigned OpNum, SStream *O,
1834
         const char *LayoutSuffix)
1835
76.5k
{
1836
76.5k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
1837
1838
76.5k
  SStream_concat0(O, "{ ");
1839
1840
  // Work out how many registers there are in the list (if there is an actual
1841
  // list).
1842
76.5k
  unsigned NumRegs = 1;
1843
76.5k
  if (MCRegisterClass_contains(
1844
76.5k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_DDRegClassID),
1845
76.5k
        Reg) ||
1846
74.5k
      MCRegisterClass_contains(
1847
74.5k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPR2RegClassID),
1848
74.5k
        Reg) ||
1849
61.9k
      MCRegisterClass_contains(
1850
61.9k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_QQRegClassID),
1851
61.9k
        Reg) ||
1852
55.2k
      MCRegisterClass_contains(
1853
55.2k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPR2RegClassID),
1854
55.2k
        Reg) ||
1855
51.3k
      MCRegisterClass_contains(
1856
51.3k
        MCRegisterInfo_getRegClass(MI->MRI,
1857
51.3k
                 AArch64_ZPR2StridedRegClassID),
1858
51.3k
        Reg))
1859
28.5k
    NumRegs = 2;
1860
47.9k
  else if (MCRegisterClass_contains(
1861
47.9k
       MCRegisterInfo_getRegClass(MI->MRI,
1862
47.9k
                AArch64_DDDRegClassID),
1863
47.9k
       Reg) ||
1864
47.3k
     MCRegisterClass_contains(
1865
47.3k
       MCRegisterInfo_getRegClass(MI->MRI,
1866
47.3k
                AArch64_ZPR3RegClassID),
1867
47.3k
       Reg) ||
1868
46.8k
     MCRegisterClass_contains(
1869
46.8k
       MCRegisterInfo_getRegClass(MI->MRI,
1870
46.8k
                AArch64_QQQRegClassID),
1871
46.8k
       Reg))
1872
9.40k
    NumRegs = 3;
1873
38.5k
  else if (MCRegisterClass_contains(
1874
38.5k
       MCRegisterInfo_getRegClass(MI->MRI,
1875
38.5k
                AArch64_DDDDRegClassID),
1876
38.5k
       Reg) ||
1877
37.4k
     MCRegisterClass_contains(
1878
37.4k
       MCRegisterInfo_getRegClass(MI->MRI,
1879
37.4k
                AArch64_ZPR4RegClassID),
1880
37.4k
       Reg) ||
1881
28.8k
     MCRegisterClass_contains(
1882
28.8k
       MCRegisterInfo_getRegClass(MI->MRI,
1883
28.8k
                AArch64_QQQQRegClassID),
1884
28.8k
       Reg) ||
1885
22.2k
     MCRegisterClass_contains(
1886
22.2k
       MCRegisterInfo_getRegClass(
1887
22.2k
         MI->MRI, AArch64_ZPR4StridedRegClassID),
1888
22.2k
       Reg))
1889
18.2k
    NumRegs = 4;
1890
1891
76.5k
  unsigned Stride = 1;
1892
76.5k
  if (MCRegisterClass_contains(
1893
76.5k
        MCRegisterInfo_getRegClass(MI->MRI,
1894
76.5k
                 AArch64_ZPR2StridedRegClassID),
1895
76.5k
        Reg))
1896
3.43k
    Stride = 8;
1897
73.0k
  else if (MCRegisterClass_contains(
1898
73.0k
       MCRegisterInfo_getRegClass(
1899
73.0k
         MI->MRI, AArch64_ZPR4StridedRegClassID),
1900
73.0k
       Reg))
1901
1.90k
    Stride = 4;
1902
1903
  // Now forget about the list and find out what the first register is.
1904
76.5k
  if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0))
1905
3.64k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0);
1906
72.8k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0))
1907
21.6k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0);
1908
51.2k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0))
1909
26.9k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0);
1910
24.2k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_psub0))
1911
3.91k
    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
76.5k
  if (MCRegisterClass_contains(MCRegisterInfo_getRegClass(
1916
76.5k
               MI->MRI, AArch64_FPR64RegClassID),
1917
76.5k
             Reg)) {
1918
3.92k
    const MCRegisterClass *FPR128RC = MCRegisterInfo_getRegClass(
1919
3.92k
      MI->MRI, AArch64_FPR128RegClassID);
1920
3.92k
    Reg = MCRegisterInfo_getMatchingSuperReg(
1921
3.92k
      MI->MRI, Reg, AArch64_dsub, FPR128RC);
1922
3.92k
  }
1923
1924
76.5k
  if ((MCRegisterClass_contains(
1925
76.5k
         MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPRRegClassID),
1926
76.5k
         Reg) ||
1927
35.0k
       MCRegisterClass_contains(
1928
35.0k
         MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPRRegClassID),
1929
35.0k
         Reg)) &&
1930
45.3k
      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
25.5k
      Reg < getNextVectorRegister(Reg, NumRegs - 1)) {
1934
24.8k
    printRegName(O, Reg);
1935
24.8k
    SStream_concat0(O, LayoutSuffix);
1936
24.8k
    if (NumRegs > 1) {
1937
      // Set of two sve registers should be separated by ','
1938
24.8k
      const char *split_char = NumRegs == 2 ? ", " : " - ";
1939
24.8k
      SStream_concat0(O, split_char);
1940
24.8k
      printRegName(O,
1941
24.8k
             (getNextVectorRegister(Reg, NumRegs - 1)));
1942
24.8k
      SStream_concat0(O, LayoutSuffix);
1943
24.8k
    }
1944
51.6k
  } else {
1945
163k
    for (unsigned i = 0; i < NumRegs;
1946
111k
         ++i, Reg = getNextVectorRegister(Reg, Stride)) {
1947
      // wrap-around sve register
1948
111k
      if (MCRegisterClass_contains(
1949
111k
            MCRegisterInfo_getRegClass(
1950
111k
              MI->MRI, AArch64_ZPRRegClassID),
1951
111k
            Reg) ||
1952
81.3k
          MCRegisterClass_contains(
1953
81.3k
            MCRegisterInfo_getRegClass(
1954
81.3k
              MI->MRI, AArch64_PPRRegClassID),
1955
81.3k
            Reg))
1956
31.1k
        printRegName(O, Reg);
1957
80.7k
      else
1958
80.7k
        printRegNameAlt(O, Reg, AArch64_vreg);
1959
111k
      SStream_concat0(O, LayoutSuffix);
1960
111k
      if (i + 1 != NumRegs)
1961
60.3k
        SStream_concat0(O, ", ");
1962
111k
    }
1963
51.6k
  }
1964
76.5k
  SStream_concat0(O, " }");
1965
76.5k
}
1966
1967
void printImplicitlyTypedVectorList(MCInst *MI, unsigned OpNum, SStream *O)
1968
0
{
1969
0
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ImplicitlyTypedVectorList,
1970
0
        OpNum);
1971
0
  printVectorList(MI, OpNum, O, "");
1972
0
}
1973
1974
#define DEFINE_printTypedVectorList(NumLanes, LaneKind) \
1975
  void CONCAT(printTypedVectorList, CONCAT(NumLanes, LaneKind))( \
1976
    MCInst * MI, unsigned OpNum, SStream *O) \
1977
76.5k
  { \
1978
76.5k
    AArch64_add_cs_detail_2( \
1979
76.5k
      MI, \
1980
76.5k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
76.5k
              NumLanes), \
1982
76.5k
             LaneKind), \
1983
76.5k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
76.5k
    if (CHAR(LaneKind) == '0') { \
1985
87
      printVectorList(MI, OpNum, O, ""); \
1986
87
      return; \
1987
87
    } \
1988
76.5k
    char Suffix[32]; \
1989
76.4k
    if (NumLanes) \
1990
76.4k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
13.2k
            CHAR(LaneKind)); \
1992
76.4k
    else \
1993
76.4k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
63.2k
            CHAR(LaneKind)); \
1995
76.4k
\
1996
76.4k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
76.4k
  }
printTypedVectorList_0_b
Line
Count
Source
1977
17.9k
  { \
1978
17.9k
    AArch64_add_cs_detail_2( \
1979
17.9k
      MI, \
1980
17.9k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
17.9k
              NumLanes), \
1982
17.9k
             LaneKind), \
1983
17.9k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
17.9k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
17.9k
    char Suffix[32]; \
1989
17.9k
    if (NumLanes) \
1990
17.9k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
17.9k
    else \
1993
17.9k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
17.9k
            CHAR(LaneKind)); \
1995
17.9k
\
1996
17.9k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
17.9k
  }
printTypedVectorList_0_d
Line
Count
Source
1977
14.2k
  { \
1978
14.2k
    AArch64_add_cs_detail_2( \
1979
14.2k
      MI, \
1980
14.2k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
14.2k
              NumLanes), \
1982
14.2k
             LaneKind), \
1983
14.2k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
14.2k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
14.2k
    char Suffix[32]; \
1989
14.2k
    if (NumLanes) \
1990
14.2k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
14.2k
    else \
1993
14.2k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
14.2k
            CHAR(LaneKind)); \
1995
14.2k
\
1996
14.2k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
14.2k
  }
printTypedVectorList_0_h
Line
Count
Source
1977
15.9k
  { \
1978
15.9k
    AArch64_add_cs_detail_2( \
1979
15.9k
      MI, \
1980
15.9k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
15.9k
              NumLanes), \
1982
15.9k
             LaneKind), \
1983
15.9k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
15.9k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
15.9k
    char Suffix[32]; \
1989
15.9k
    if (NumLanes) \
1990
15.9k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
15.9k
    else \
1993
15.9k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
15.9k
            CHAR(LaneKind)); \
1995
15.9k
\
1996
15.9k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
15.9k
  }
printTypedVectorList_0_s
Line
Count
Source
1977
14.4k
  { \
1978
14.4k
    AArch64_add_cs_detail_2( \
1979
14.4k
      MI, \
1980
14.4k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
14.4k
              NumLanes), \
1982
14.4k
             LaneKind), \
1983
14.4k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
14.4k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
14.4k
    char Suffix[32]; \
1989
14.4k
    if (NumLanes) \
1990
14.4k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
14.4k
    else \
1993
14.4k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
14.4k
            CHAR(LaneKind)); \
1995
14.4k
\
1996
14.4k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
14.4k
  }
printTypedVectorList_0_q
Line
Count
Source
1977
635
  { \
1978
635
    AArch64_add_cs_detail_2( \
1979
635
      MI, \
1980
635
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
635
              NumLanes), \
1982
635
             LaneKind), \
1983
635
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
635
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
635
    char Suffix[32]; \
1989
635
    if (NumLanes) \
1990
635
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
0
            CHAR(LaneKind)); \
1992
635
    else \
1993
635
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
635
            CHAR(LaneKind)); \
1995
635
\
1996
635
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
635
  }
printTypedVectorList_16_b
Line
Count
Source
1977
3.00k
  { \
1978
3.00k
    AArch64_add_cs_detail_2( \
1979
3.00k
      MI, \
1980
3.00k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
3.00k
              NumLanes), \
1982
3.00k
             LaneKind), \
1983
3.00k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
3.00k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
3.00k
    char Suffix[32]; \
1989
3.00k
    if (NumLanes) \
1990
3.00k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
3.00k
            CHAR(LaneKind)); \
1992
3.00k
    else \
1993
3.00k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
3.00k
\
1996
3.00k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
3.00k
  }
printTypedVectorList_1_d
Line
Count
Source
1977
214
  { \
1978
214
    AArch64_add_cs_detail_2( \
1979
214
      MI, \
1980
214
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
214
              NumLanes), \
1982
214
             LaneKind), \
1983
214
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
214
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
214
    char Suffix[32]; \
1989
214
    if (NumLanes) \
1990
214
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
214
            CHAR(LaneKind)); \
1992
214
    else \
1993
214
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
214
\
1996
214
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
214
  }
printTypedVectorList_2_d
Line
Count
Source
1977
1.63k
  { \
1978
1.63k
    AArch64_add_cs_detail_2( \
1979
1.63k
      MI, \
1980
1.63k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.63k
              NumLanes), \
1982
1.63k
             LaneKind), \
1983
1.63k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.63k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.63k
    char Suffix[32]; \
1989
1.63k
    if (NumLanes) \
1990
1.63k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.63k
            CHAR(LaneKind)); \
1992
1.63k
    else \
1993
1.63k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.63k
\
1996
1.63k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.63k
  }
printTypedVectorList_2_s
Line
Count
Source
1977
1.08k
  { \
1978
1.08k
    AArch64_add_cs_detail_2( \
1979
1.08k
      MI, \
1980
1.08k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.08k
              NumLanes), \
1982
1.08k
             LaneKind), \
1983
1.08k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.08k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.08k
    char Suffix[32]; \
1989
1.08k
    if (NumLanes) \
1990
1.08k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.08k
            CHAR(LaneKind)); \
1992
1.08k
    else \
1993
1.08k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.08k
\
1996
1.08k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.08k
  }
printTypedVectorList_4_h
Line
Count
Source
1977
1.36k
  { \
1978
1.36k
    AArch64_add_cs_detail_2( \
1979
1.36k
      MI, \
1980
1.36k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.36k
              NumLanes), \
1982
1.36k
             LaneKind), \
1983
1.36k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.36k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.36k
    char Suffix[32]; \
1989
1.36k
    if (NumLanes) \
1990
1.36k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.36k
            CHAR(LaneKind)); \
1992
1.36k
    else \
1993
1.36k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.36k
\
1996
1.36k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.36k
  }
printTypedVectorList_4_s
Line
Count
Source
1977
1.99k
  { \
1978
1.99k
    AArch64_add_cs_detail_2( \
1979
1.99k
      MI, \
1980
1.99k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.99k
              NumLanes), \
1982
1.99k
             LaneKind), \
1983
1.99k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.99k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.99k
    char Suffix[32]; \
1989
1.99k
    if (NumLanes) \
1990
1.99k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.99k
            CHAR(LaneKind)); \
1992
1.99k
    else \
1993
1.99k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.99k
\
1996
1.99k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.99k
  }
printTypedVectorList_8_b
Line
Count
Source
1977
1.26k
  { \
1978
1.26k
    AArch64_add_cs_detail_2( \
1979
1.26k
      MI, \
1980
1.26k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
1.26k
              NumLanes), \
1982
1.26k
             LaneKind), \
1983
1.26k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
1.26k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
1.26k
    char Suffix[32]; \
1989
1.26k
    if (NumLanes) \
1990
1.26k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
1.26k
            CHAR(LaneKind)); \
1992
1.26k
    else \
1993
1.26k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
1.26k
\
1996
1.26k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
1.26k
  }
printTypedVectorList_8_h
Line
Count
Source
1977
2.64k
  { \
1978
2.64k
    AArch64_add_cs_detail_2( \
1979
2.64k
      MI, \
1980
2.64k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
2.64k
              NumLanes), \
1982
2.64k
             LaneKind), \
1983
2.64k
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
2.64k
    if (CHAR(LaneKind) == '0') { \
1985
0
      printVectorList(MI, OpNum, O, ""); \
1986
0
      return; \
1987
0
    } \
1988
2.64k
    char Suffix[32]; \
1989
2.64k
    if (NumLanes) \
1990
2.64k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1991
2.64k
            CHAR(LaneKind)); \
1992
2.64k
    else \
1993
2.64k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1994
0
            CHAR(LaneKind)); \
1995
2.64k
\
1996
2.64k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1997
2.64k
  }
printTypedVectorList_0_0
Line
Count
Source
1977
87
  { \
1978
87
    AArch64_add_cs_detail_2( \
1979
87
      MI, \
1980
87
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1981
87
              NumLanes), \
1982
87
             LaneKind), \
1983
87
      OpNum, NumLanes, CHAR(LaneKind)); \
1984
87
    if (CHAR(LaneKind) == '0') { \
1985
87
      printVectorList(MI, OpNum, O, ""); \
1986
87
      return; \
1987
87
    } \
1988
87
    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
42.6k
  { \
2017
42.6k
    AArch64_add_cs_detail_1( \
2018
42.6k
      MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \
2019
42.6k
      OpNum, Scale); \
2020
42.6k
    SStream_concat(O, "%s", "["); \
2021
42.6k
    printUInt64(O, Scale *MCOperand_getImm( \
2022
42.6k
               MCInst_getOperand(MI, (OpNum)))); \
2023
42.6k
    SStream_concat0(O, "]"); \
2024
42.6k
  }
printVectorIndex_1
Line
Count
Source
2016
42.6k
  { \
2017
42.6k
    AArch64_add_cs_detail_1( \
2018
42.6k
      MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \
2019
42.6k
      OpNum, Scale); \
2020
42.6k
    SStream_concat(O, "%s", "["); \
2021
42.6k
    printUInt64(O, Scale *MCOperand_getImm( \
2022
42.6k
               MCInst_getOperand(MI, (OpNum)))); \
2023
42.6k
    SStream_concat0(O, "]"); \
2024
42.6k
  }
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
14.6k
{
2030
14.6k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AlignedLabel, OpNum);
2031
14.6k
  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
14.6k
  if (MCOperand_isImm(Op)) {
2036
14.6k
    SStream_concat0(O, markup("<imm:"));
2037
14.6k
    int64_t Offset = MCOperand_getImm(Op) * 4;
2038
14.6k
    if (MI->csh->PrintBranchImmAsAddress)
2039
14.6k
      printUInt64(O, (Address + Offset));
2040
0
    else {
2041
0
      printUInt64Bang(O, (Offset));
2042
0
    }
2043
14.6k
    SStream_concat0(O, markup(">"));
2044
14.6k
    return;
2045
14.6k
  }
2046
2047
88
  printUInt64Bang(O, MCOperand_getImm(Op));
2048
88
}
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.58k
{
2096
5.58k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AdrAdrpLabel, OpNum);
2097
5.58k
  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.58k
  if (MCOperand_isImm(Op)) {
2102
5.58k
    int64_t Offset = MCOperand_getImm(Op);
2103
5.58k
    if (MCInst_getOpcode(MI) == AArch64_ADRP) {
2104
1.71k
      Offset = Offset * 4096;
2105
1.71k
      Address = Address & -4096;
2106
1.71k
    }
2107
5.58k
    SStream_concat0(O, markup(">"));
2108
5.58k
    if (MI->csh->PrintBranchImmAsAddress)
2109
5.58k
      printUInt64(O, (Address + Offset));
2110
0
    else {
2111
0
      printUInt64Bang(O, Offset);
2112
0
    }
2113
5.58k
    SStream_concat0(O, markup(">"));
2114
5.58k
    return;
2115
5.58k
  }
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
918
{
2125
918
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AppleSysBarrierOption,
2126
918
        OpNo);
2127
918
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2128
918
  switch (Val) {
2129
501
  default:
2130
501
    SStream_concat0(O, "<undefined>");
2131
501
    break;
2132
45
  case 0:
2133
45
    SStream_concat0(O, "osh");
2134
45
    break;
2135
247
  case 1:
2136
247
    SStream_concat0(O, "nsh");
2137
247
    break;
2138
25
  case 2:
2139
25
    SStream_concat0(O, "ish");
2140
25
    break;
2141
100
  case 3:
2142
100
    SStream_concat0(O, "sy");
2143
100
    break;
2144
918
  }
2145
918
}
2146
2147
void printBarrierOption(MCInst *MI, unsigned OpNo, SStream *O)
2148
520
{
2149
520
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarrierOption, OpNo);
2150
520
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2151
520
  unsigned Opcode = MCInst_getOpcode(MI);
2152
2153
520
  const char *Name;
2154
520
  if (Opcode == AArch64_ISB) {
2155
35
    const AArch64ISB_ISB *ISB = AArch64ISB_lookupISBByEncoding(Val);
2156
35
    Name = ISB ? ISB->Name : "";
2157
485
  } else if (Opcode == AArch64_TSB) {
2158
240
    const AArch64TSB_TSB *TSB = AArch64TSB_lookupTSBByEncoding(Val);
2159
240
    Name = TSB ? TSB->Name : "";
2160
245
  } else {
2161
245
    const AArch64DB_DB *DB = AArch64DB_lookupDBByEncoding(Val);
2162
245
    Name = DB ? DB->Name : "";
2163
245
  }
2164
520
  if (Name[0] != '\0')
2165
421
    SStream_concat0(O, Name);
2166
99
  else {
2167
99
    SStream_concat(O, "%s", markup("<imm:"));
2168
99
    printUInt32Bang(O, Val);
2169
99
    SStream_concat0(O, markup(">"));
2170
99
  }
2171
520
}
2172
2173
void printBarriernXSOption(MCInst *MI, unsigned OpNo, SStream *O)
2174
1.17k
{
2175
1.17k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarriernXSOption, OpNo);
2176
1.17k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2177
2178
1.17k
  const char *Name;
2179
1.17k
  const AArch64DBnXS_DBnXS *DB = AArch64DBnXS_lookupDBnXSByEncoding(Val);
2180
1.17k
  Name = DB ? DB->Name : "";
2181
2182
1.17k
  if (Name[0] != '\0')
2183
1.17k
    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.17k
}
2189
2190
static bool isValidSysReg(const AArch64SysReg_SysReg *Reg, bool Read,
2191
        unsigned mode)
2192
8.13k
{
2193
8.13k
  return (Reg && (Read ? Reg->Readable : Reg->Writeable) &&
2194
1.29k
    AArch64_testFeatureList(mode, Reg->FeaturesRequired));
2195
8.13k
}
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
6.59k
{
2206
6.59k
  const AArch64SysReg_SysReg *Reg =
2207
6.59k
    AArch64SysReg_lookupSysRegByEncoding(Val);
2208
2209
6.59k
  if (Reg && !isValidSysReg(Reg, Read, mode))
2210
902
    Reg = AArch64SysReg_lookupSysRegByName(Reg->AltName);
2211
2212
6.59k
  return Reg;
2213
6.59k
}
2214
2215
void printMRSSystemRegister(MCInst *MI, unsigned OpNo, SStream *O)
2216
1.68k
{
2217
1.68k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MRSSystemRegister, OpNo);
2218
1.68k
  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.68k
  if (Val == AARCH64_SYSREG_DBGDTRRX_EL0) {
2224
209
    SStream_concat0(O, "DBGDTRRX_EL0");
2225
209
    return;
2226
209
  }
2227
2228
  // Horrible hack for two different registers having the same encoding.
2229
1.47k
  if (Val == AARCH64_SYSREG_TRCEXTINSELR) {
2230
49
    SStream_concat0(O, "TRCEXTINSELR");
2231
49
    return;
2232
49
  }
2233
2234
1.42k
  const AArch64SysReg_SysReg *Reg =
2235
1.42k
    lookupSysReg(Val, true /*Read*/, MI->csh->mode);
2236
2237
1.42k
  if (isValidSysReg(Reg, true /*Read*/, MI->csh->mode))
2238
211
    SStream_concat0(O, Reg->Name);
2239
1.21k
  else {
2240
1.21k
    char result[AARCH64_GRS_LEN + 1] = { 0 };
2241
1.21k
    AArch64SysReg_genericRegisterString(Val, result);
2242
1.21k
    SStream_concat0(O, result);
2243
1.21k
  }
2244
1.42k
}
2245
2246
void printMSRSystemRegister(MCInst *MI, unsigned OpNo, SStream *O)
2247
5.33k
{
2248
5.33k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MSRSystemRegister, OpNo);
2249
5.33k
  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
5.33k
  if (Val == AARCH64_SYSREG_DBGDTRTX_EL0) {
2255
152
    SStream_concat0(O, "DBGDTRTX_EL0");
2256
152
    return;
2257
152
  }
2258
2259
  // Horrible hack for two different registers having the same encoding.
2260
5.17k
  if (Val == AARCH64_SYSREG_TRCEXTINSELR) {
2261
15
    SStream_concat0(O, "TRCEXTINSELR");
2262
15
    return;
2263
15
  }
2264
2265
5.16k
  const AArch64SysReg_SysReg *Reg =
2266
5.16k
    lookupSysReg(Val, false /*Read*/, MI->csh->mode);
2267
2268
5.16k
  if (isValidSysReg(Reg, false /*Read*/, MI->csh->mode))
2269
435
    SStream_concat0(O, Reg->Name);
2270
4.72k
  else {
2271
4.72k
    char result[AARCH64_GRS_LEN + 1] = { 0 };
2272
4.72k
    AArch64SysReg_genericRegisterString(Val, result);
2273
4.72k
    SStream_concat0(O, result);
2274
4.72k
  }
2275
5.16k
}
2276
2277
void printSystemPStateField(MCInst *MI, unsigned OpNo, SStream *O)
2278
979
{
2279
979
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SystemPStateField, OpNo);
2280
979
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2281
2282
979
  const AArch64PState_PStateImm0_15 *PStateImm15 =
2283
979
    AArch64PState_lookupPStateImm0_15ByEncoding(Val);
2284
979
  const AArch64PState_PStateImm0_1 *PStateImm1 =
2285
979
    AArch64PState_lookupPStateImm0_1ByEncoding(Val);
2286
979
  if (PStateImm15 &&
2287
801
      AArch64_testFeatureList(MI->csh->mode,
2288
801
            PStateImm15->FeaturesRequired))
2289
801
    SStream_concat0(O, PStateImm15->Name);
2290
178
  else if (PStateImm1 &&
2291
178
     AArch64_testFeatureList(MI->csh->mode,
2292
178
           PStateImm1->FeaturesRequired))
2293
178
    SStream_concat0(O, PStateImm1->Name);
2294
0
  else {
2295
0
    printUInt32Bang(O, (Val));
2296
0
    SStream_concat1(O, '\0');
2297
0
  }
2298
979
}
2299
2300
void printSIMDType10Operand(MCInst *MI, unsigned OpNo, SStream *O)
2301
1.79k
{
2302
1.79k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SIMDType10Operand, OpNo);
2303
1.79k
  unsigned RawVal = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2304
1.79k
  uint64_t Val = AArch64_AM_decodeAdvSIMDModImmType10(RawVal);
2305
1.79k
  SStream_concat(O, "%s#%#016llx", markup("<imm:"), Val);
2306
1.79k
  SStream_concat0(O, markup(">"));
2307
1.79k
}
2308
2309
#define DEFINE_printComplexRotationOp(Angle, Remainder) \
2310
  static void CONCAT(printComplexRotationOp, CONCAT(Angle, Remainder))( \
2311
    MCInst * MI, unsigned OpNo, SStream *O) \
2312
3.63k
  { \
2313
3.63k
    AArch64_add_cs_detail_2( \
2314
3.63k
      MI, \
2315
3.63k
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2316
3.63k
              Angle), \
2317
3.63k
             Remainder), \
2318
3.63k
      OpNo, Angle, Remainder); \
2319
3.63k
    unsigned Val = \
2320
3.63k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2321
3.63k
    SStream_concat(O, "%s", markup("<imm:")); \
2322
3.63k
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2323
3.63k
    SStream_concat0(O, markup(">")); \
2324
3.63k
  }
AArch64InstPrinter.c:printComplexRotationOp_180_90
Line
Count
Source
2312
517
  { \
2313
517
    AArch64_add_cs_detail_2( \
2314
517
      MI, \
2315
517
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2316
517
              Angle), \
2317
517
             Remainder), \
2318
517
      OpNo, Angle, Remainder); \
2319
517
    unsigned Val = \
2320
517
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2321
517
    SStream_concat(O, "%s", markup("<imm:")); \
2322
517
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2323
517
    SStream_concat0(O, markup(">")); \
2324
517
  }
AArch64InstPrinter.c:printComplexRotationOp_90_0
Line
Count
Source
2312
3.11k
  { \
2313
3.11k
    AArch64_add_cs_detail_2( \
2314
3.11k
      MI, \
2315
3.11k
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2316
3.11k
              Angle), \
2317
3.11k
             Remainder), \
2318
3.11k
      OpNo, Angle, Remainder); \
2319
3.11k
    unsigned Val = \
2320
3.11k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2321
3.11k
    SStream_concat(O, "%s", markup("<imm:")); \
2322
3.11k
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2323
3.11k
    SStream_concat0(O, markup(">")); \
2324
3.11k
  }
2325
DEFINE_printComplexRotationOp(180, 90);
2326
DEFINE_printComplexRotationOp(90, 0);
2327
2328
void printSVEPattern(MCInst *MI, unsigned OpNum, SStream *O)
2329
6.95k
{
2330
6.95k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEPattern, OpNum);
2331
6.95k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
2332
6.95k
  const AArch64SVEPredPattern_SVEPREDPAT *Pat =
2333
6.95k
    AArch64SVEPredPattern_lookupSVEPREDPATByEncoding(Val);
2334
6.95k
  if (Pat)
2335
3.90k
    SStream_concat0(O, Pat->Name);
2336
3.05k
  else
2337
3.05k
    printUInt32Bang(O, Val);
2338
6.95k
}
2339
2340
void printSVEVecLenSpecifier(MCInst *MI, unsigned OpNum, SStream *O)
2341
1.56k
{
2342
1.56k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEVecLenSpecifier, OpNum);
2343
1.56k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
2344
  // Pattern has only 1 bit
2345
1.56k
  if (Val > 1)
2346
0
    CS_ASSERT_RET(0 && "Invalid vector length specifier");
2347
1.56k
  const AArch64SVEVecLenSpecifier_SVEVECLENSPECIFIER *Pat =
2348
1.56k
    AArch64SVEVecLenSpecifier_lookupSVEVECLENSPECIFIERByEncoding(
2349
1.56k
      Val);
2350
1.56k
  if (Pat)
2351
1.56k
    SStream_concat0(O, Pat->Name);
2352
1.56k
}
2353
2354
#define DEFINE_printSVERegOp(suffix) \
2355
  void CONCAT(printSVERegOp, suffix)(MCInst * MI, unsigned OpNum, \
2356
             SStream *O) \
2357
205k
  { \
2358
205k
    AArch64_add_cs_detail_1( \
2359
205k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
205k
      CHAR(suffix)); \
2361
205k
    switch (CHAR(suffix)) { \
2362
62.3k
    case '0': \
2363
99.1k
    case 'b': \
2364
141k
    case 'h': \
2365
169k
    case 's': \
2366
203k
    case 'd': \
2367
205k
    case 'q': \
2368
205k
      break; \
2369
203k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
205k
    } \
2372
205k
\
2373
205k
    unsigned Reg = \
2374
205k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
205k
    printRegName(O, Reg); \
2376
205k
    if (CHAR(suffix) != '0') { \
2377
143k
      SStream_concat1(O, '.'); \
2378
143k
      SStream_concat1(O, CHAR(suffix)); \
2379
143k
    } \
2380
205k
  }
printSVERegOp_b
Line
Count
Source
2357
36.8k
  { \
2358
36.8k
    AArch64_add_cs_detail_1( \
2359
36.8k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
36.8k
      CHAR(suffix)); \
2361
36.8k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
36.8k
    case 'b': \
2364
36.8k
    case 'h': \
2365
36.8k
    case 's': \
2366
36.8k
    case 'd': \
2367
36.8k
    case 'q': \
2368
36.8k
      break; \
2369
36.8k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
36.8k
    } \
2372
36.8k
\
2373
36.8k
    unsigned Reg = \
2374
36.8k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
36.8k
    printRegName(O, Reg); \
2376
36.8k
    if (CHAR(suffix) != '0') { \
2377
36.8k
      SStream_concat1(O, '.'); \
2378
36.8k
      SStream_concat1(O, CHAR(suffix)); \
2379
36.8k
    } \
2380
36.8k
  }
printSVERegOp_d
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
0
    case 'b': \
2364
0
    case 'h': \
2365
0
    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_h
Line
Count
Source
2357
42.4k
  { \
2358
42.4k
    AArch64_add_cs_detail_1( \
2359
42.4k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
42.4k
      CHAR(suffix)); \
2361
42.4k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
0
    case 'b': \
2364
42.4k
    case 'h': \
2365
42.4k
    case 's': \
2366
42.4k
    case 'd': \
2367
42.4k
    case 'q': \
2368
42.4k
      break; \
2369
42.4k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
42.4k
    } \
2372
42.4k
\
2373
42.4k
    unsigned Reg = \
2374
42.4k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
42.4k
    printRegName(O, Reg); \
2376
42.4k
    if (CHAR(suffix) != '0') { \
2377
42.4k
      SStream_concat1(O, '.'); \
2378
42.4k
      SStream_concat1(O, CHAR(suffix)); \
2379
42.4k
    } \
2380
42.4k
  }
printSVERegOp_s
Line
Count
Source
2357
28.1k
  { \
2358
28.1k
    AArch64_add_cs_detail_1( \
2359
28.1k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
28.1k
      CHAR(suffix)); \
2361
28.1k
    switch (CHAR(suffix)) { \
2362
0
    case '0': \
2363
0
    case 'b': \
2364
0
    case 'h': \
2365
28.1k
    case 's': \
2366
28.1k
    case 'd': \
2367
28.1k
    case 'q': \
2368
28.1k
      break; \
2369
28.1k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
28.1k
    } \
2372
28.1k
\
2373
28.1k
    unsigned Reg = \
2374
28.1k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
28.1k
    printRegName(O, Reg); \
2376
28.1k
    if (CHAR(suffix) != '0') { \
2377
28.1k
      SStream_concat1(O, '.'); \
2378
28.1k
      SStream_concat1(O, CHAR(suffix)); \
2379
28.1k
    } \
2380
28.1k
  }
printSVERegOp_0
Line
Count
Source
2357
62.3k
  { \
2358
62.3k
    AArch64_add_cs_detail_1( \
2359
62.3k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
62.3k
      CHAR(suffix)); \
2361
62.3k
    switch (CHAR(suffix)) { \
2362
62.3k
    case '0': \
2363
62.3k
    case 'b': \
2364
62.3k
    case 'h': \
2365
62.3k
    case 's': \
2366
62.3k
    case 'd': \
2367
62.3k
    case 'q': \
2368
62.3k
      break; \
2369
62.3k
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
62.3k
    } \
2372
62.3k
\
2373
62.3k
    unsigned Reg = \
2374
62.3k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
62.3k
    printRegName(O, Reg); \
2376
62.3k
    if (CHAR(suffix) != '0') { \
2377
0
      SStream_concat1(O, '.'); \
2378
0
      SStream_concat1(O, CHAR(suffix)); \
2379
0
    } \
2380
62.3k
  }
printSVERegOp_q
Line
Count
Source
2357
2.22k
  { \
2358
2.22k
    AArch64_add_cs_detail_1( \
2359
2.22k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2360
2.22k
      CHAR(suffix)); \
2361
2.22k
    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.22k
    case 'q': \
2368
2.22k
      break; \
2369
0
    default: \
2370
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2371
2.22k
    } \
2372
2.22k
\
2373
2.22k
    unsigned Reg = \
2374
2.22k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2375
2.22k
    printRegName(O, Reg); \
2376
2.22k
    if (CHAR(suffix) != '0') { \
2377
2.22k
      SStream_concat1(O, '.'); \
2378
2.22k
      SStream_concat1(O, CHAR(suffix)); \
2379
2.22k
    } \
2380
2.22k
  }
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
3.21k
  { \
2391
3.21k
    printInt32Bang(O, Val); \
2392
3.21k
  }
printImmSVE_int16_t
Line
Count
Source
2390
1.44k
  { \
2391
1.44k
    printInt32Bang(O, Val); \
2392
1.44k
  }
printImmSVE_int8_t
Line
Count
Source
2390
546
  { \
2391
546
    printInt32Bang(O, Val); \
2392
546
  }
printImmSVE_int32_t
Line
Count
Source
2390
1.22k
  { \
2391
1.22k
    printInt32Bang(O, Val); \
2392
1.22k
  }
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
907
  { \
2400
907
    printUInt32Bang(O, Val); \
2401
907
  }
printImmSVE_uint16_t
Line
Count
Source
2399
304
  { \
2400
304
    printUInt32Bang(O, Val); \
2401
304
  }
printImmSVE_uint8_t
Line
Count
Source
2399
269
  { \
2400
269
    printUInt32Bang(O, Val); \
2401
269
  }
printImmSVE_uint32_t
Line
Count
Source
2399
334
  { \
2400
334
    printUInt32Bang(O, Val); \
2401
334
  }
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
1.33k
  { \
2409
1.33k
    printInt64Bang(O, Val); \
2410
1.33k
  }
2411
DECLARE_printImmSVE_S64(int64_t);
2412
2413
#define DECLARE_printImmSVE_U64(T) \
2414
  void CONCAT(printImmSVE, T)(T Val, SStream * O) \
2415
386
  { \
2416
386
    printUInt64Bang(O, Val); \
2417
386
  }
2418
DECLARE_printImmSVE_U64(uint64_t);
2419
2420
#define DEFINE_isSignedType(T) \
2421
  static inline bool CONCAT(isSignedType, T)() \
2422
3.22k
  { \
2423
3.22k
    return CHAR(T) == 'i'; \
2424
3.22k
  }
AArch64InstPrinter.c:isSignedType_int16_t
Line
Count
Source
2422
486
  { \
2423
486
    return CHAR(T) == 'i'; \
2424
486
  }
AArch64InstPrinter.c:isSignedType_int8_t
Line
Count
Source
2422
546
  { \
2423
546
    return CHAR(T) == 'i'; \
2424
546
  }
AArch64InstPrinter.c:isSignedType_int64_t
Line
Count
Source
2422
683
  { \
2423
683
    return CHAR(T) == 'i'; \
2424
683
  }
AArch64InstPrinter.c:isSignedType_int32_t
Line
Count
Source
2422
212
  { \
2423
212
    return CHAR(T) == 'i'; \
2424
212
  }
AArch64InstPrinter.c:isSignedType_uint16_t
Line
Count
Source
2422
304
  { \
2423
304
    return CHAR(T) == 'i'; \
2424
304
  }
AArch64InstPrinter.c:isSignedType_uint8_t
Line
Count
Source
2422
269
  { \
2423
269
    return CHAR(T) == 'i'; \
2424
269
  }
AArch64InstPrinter.c:isSignedType_uint64_t
Line
Count
Source
2422
386
  { \
2423
386
    return CHAR(T) == 'i'; \
2424
386
  }
AArch64InstPrinter.c:isSignedType_uint32_t
Line
Count
Source
2422
334
  { \
2423
334
    return CHAR(T) == 'i'; \
2424
334
  }
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.39k
  { \
2438
4.39k
    AArch64_add_cs_detail_1( \
2439
4.39k
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
4.39k
      sizeof(T)); \
2441
4.39k
    unsigned UnscaledVal = \
2442
4.39k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
4.39k
    unsigned Shift = \
2444
4.39k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
4.39k
\
2446
4.39k
    if ((UnscaledVal == 0) && \
2447
4.39k
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
1.17k
      SStream_concat(O, "%s", markup("<imm:")); \
2449
1.17k
      SStream_concat1(O, '#'); \
2450
1.17k
      printUInt64(O, (UnscaledVal)); \
2451
1.17k
      SStream_concat0(O, markup(">")); \
2452
1.17k
      printShifter(MI, OpNum + 1, O); \
2453
1.17k
      return; \
2454
1.17k
    } \
2455
4.39k
\
2456
4.39k
    T Val; \
2457
3.22k
    if (CONCAT(isSignedType, T)()) \
2458
3.22k
      Val = (int8_t)UnscaledVal * \
2459
1.92k
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
3.22k
    else \
2461
3.22k
      Val = (uint8_t)UnscaledVal * \
2462
1.29k
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
3.22k
\
2464
3.22k
    CONCAT(printImmSVE, T)(Val, O); \
2465
3.22k
  }
printImm8OptLsl_int16_t
Line
Count
Source
2437
557
  { \
2438
557
    AArch64_add_cs_detail_1( \
2439
557
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
557
      sizeof(T)); \
2441
557
    unsigned UnscaledVal = \
2442
557
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
557
    unsigned Shift = \
2444
557
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
557
\
2446
557
    if ((UnscaledVal == 0) && \
2447
557
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
71
      SStream_concat(O, "%s", markup("<imm:")); \
2449
71
      SStream_concat1(O, '#'); \
2450
71
      printUInt64(O, (UnscaledVal)); \
2451
71
      SStream_concat0(O, markup(">")); \
2452
71
      printShifter(MI, OpNum + 1, O); \
2453
71
      return; \
2454
71
    } \
2455
557
\
2456
557
    T Val; \
2457
486
    if (CONCAT(isSignedType, T)()) \
2458
486
      Val = (int8_t)UnscaledVal * \
2459
486
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
486
    else \
2461
486
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
486
\
2464
486
    CONCAT(printImmSVE, T)(Val, O); \
2465
486
  }
printImm8OptLsl_int8_t
Line
Count
Source
2437
546
  { \
2438
546
    AArch64_add_cs_detail_1( \
2439
546
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
546
      sizeof(T)); \
2441
546
    unsigned UnscaledVal = \
2442
546
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
546
    unsigned Shift = \
2444
546
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
546
\
2446
546
    if ((UnscaledVal == 0) && \
2447
546
        (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
546
\
2456
546
    T Val; \
2457
546
    if (CONCAT(isSignedType, T)()) \
2458
546
      Val = (int8_t)UnscaledVal * \
2459
546
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
546
    else \
2461
546
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
546
\
2464
546
    CONCAT(printImmSVE, T)(Val, O); \
2465
546
  }
printImm8OptLsl_int64_t
Line
Count
Source
2437
794
  { \
2438
794
    AArch64_add_cs_detail_1( \
2439
794
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
794
      sizeof(T)); \
2441
794
    unsigned UnscaledVal = \
2442
794
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
794
    unsigned Shift = \
2444
794
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
794
\
2446
794
    if ((UnscaledVal == 0) && \
2447
794
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
111
      SStream_concat(O, "%s", markup("<imm:")); \
2449
111
      SStream_concat1(O, '#'); \
2450
111
      printUInt64(O, (UnscaledVal)); \
2451
111
      SStream_concat0(O, markup(">")); \
2452
111
      printShifter(MI, OpNum + 1, O); \
2453
111
      return; \
2454
111
    } \
2455
794
\
2456
794
    T Val; \
2457
683
    if (CONCAT(isSignedType, T)()) \
2458
683
      Val = (int8_t)UnscaledVal * \
2459
683
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
683
    else \
2461
683
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
683
\
2464
683
    CONCAT(printImmSVE, T)(Val, O); \
2465
683
  }
printImm8OptLsl_int32_t
Line
Count
Source
2437
420
  { \
2438
420
    AArch64_add_cs_detail_1( \
2439
420
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
420
      sizeof(T)); \
2441
420
    unsigned UnscaledVal = \
2442
420
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
420
    unsigned Shift = \
2444
420
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
420
\
2446
420
    if ((UnscaledVal == 0) && \
2447
420
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
208
      SStream_concat(O, "%s", markup("<imm:")); \
2449
208
      SStream_concat1(O, '#'); \
2450
208
      printUInt64(O, (UnscaledVal)); \
2451
208
      SStream_concat0(O, markup(">")); \
2452
208
      printShifter(MI, OpNum + 1, O); \
2453
208
      return; \
2454
208
    } \
2455
420
\
2456
420
    T Val; \
2457
212
    if (CONCAT(isSignedType, T)()) \
2458
212
      Val = (int8_t)UnscaledVal * \
2459
212
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
212
    else \
2461
212
      Val = (uint8_t)UnscaledVal * \
2462
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
212
\
2464
212
    CONCAT(printImmSVE, T)(Val, O); \
2465
212
  }
printImm8OptLsl_uint16_t
Line
Count
Source
2437
357
  { \
2438
357
    AArch64_add_cs_detail_1( \
2439
357
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
357
      sizeof(T)); \
2441
357
    unsigned UnscaledVal = \
2442
357
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
357
    unsigned Shift = \
2444
357
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
357
\
2446
357
    if ((UnscaledVal == 0) && \
2447
357
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
53
      SStream_concat(O, "%s", markup("<imm:")); \
2449
53
      SStream_concat1(O, '#'); \
2450
53
      printUInt64(O, (UnscaledVal)); \
2451
53
      SStream_concat0(O, markup(">")); \
2452
53
      printShifter(MI, OpNum + 1, O); \
2453
53
      return; \
2454
53
    } \
2455
357
\
2456
357
    T Val; \
2457
304
    if (CONCAT(isSignedType, T)()) \
2458
304
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
304
    else \
2461
304
      Val = (uint8_t)UnscaledVal * \
2462
304
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
304
\
2464
304
    CONCAT(printImmSVE, T)(Val, O); \
2465
304
  }
printImm8OptLsl_uint8_t
Line
Count
Source
2437
269
  { \
2438
269
    AArch64_add_cs_detail_1( \
2439
269
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
269
      sizeof(T)); \
2441
269
    unsigned UnscaledVal = \
2442
269
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
269
    unsigned Shift = \
2444
269
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
269
\
2446
269
    if ((UnscaledVal == 0) && \
2447
269
        (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
269
\
2456
269
    T Val; \
2457
269
    if (CONCAT(isSignedType, T)()) \
2458
269
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
269
    else \
2461
269
      Val = (uint8_t)UnscaledVal * \
2462
269
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
269
\
2464
269
    CONCAT(printImmSVE, T)(Val, O); \
2465
269
  }
printImm8OptLsl_uint64_t
Line
Count
Source
2437
994
  { \
2438
994
    AArch64_add_cs_detail_1( \
2439
994
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
994
      sizeof(T)); \
2441
994
    unsigned UnscaledVal = \
2442
994
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
994
    unsigned Shift = \
2444
994
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
994
\
2446
994
    if ((UnscaledVal == 0) && \
2447
994
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
608
      SStream_concat(O, "%s", markup("<imm:")); \
2449
608
      SStream_concat1(O, '#'); \
2450
608
      printUInt64(O, (UnscaledVal)); \
2451
608
      SStream_concat0(O, markup(">")); \
2452
608
      printShifter(MI, OpNum + 1, O); \
2453
608
      return; \
2454
608
    } \
2455
994
\
2456
994
    T Val; \
2457
386
    if (CONCAT(isSignedType, T)()) \
2458
386
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
386
    else \
2461
386
      Val = (uint8_t)UnscaledVal * \
2462
386
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
386
\
2464
386
    CONCAT(printImmSVE, T)(Val, O); \
2465
386
  }
printImm8OptLsl_uint32_t
Line
Count
Source
2437
455
  { \
2438
455
    AArch64_add_cs_detail_1( \
2439
455
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, \
2440
455
      sizeof(T)); \
2441
455
    unsigned UnscaledVal = \
2442
455
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2443
455
    unsigned Shift = \
2444
455
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2445
455
\
2446
455
    if ((UnscaledVal == 0) && \
2447
455
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2448
121
      SStream_concat(O, "%s", markup("<imm:")); \
2449
121
      SStream_concat1(O, '#'); \
2450
121
      printUInt64(O, (UnscaledVal)); \
2451
121
      SStream_concat0(O, markup(">")); \
2452
121
      printShifter(MI, OpNum + 1, O); \
2453
121
      return; \
2454
121
    } \
2455
455
\
2456
455
    T Val; \
2457
334
    if (CONCAT(isSignedType, T)()) \
2458
334
      Val = (int8_t)UnscaledVal * \
2459
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2460
334
    else \
2461
334
      Val = (uint8_t)UnscaledVal * \
2462
334
            (1 << AArch64_AM_getShiftValue(Shift)); \
2463
334
\
2464
334
    CONCAT(printImmSVE, T)(Val, O); \
2465
334
  }
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.83k
  { \
2479
3.83k
    AArch64_add_cs_detail_1( \
2480
3.83k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
3.83k
      sizeof(T)); \
2482
3.83k
    typedef T SignedT; \
2483
3.83k
    typedef CONCATS(u, T) UnsignedT; \
2484
3.83k
\
2485
3.83k
    uint64_t Val = \
2486
3.83k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
3.83k
    UnsignedT PrintVal = \
2488
3.83k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
3.83k
\
2490
3.83k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
3.83k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
3.83k
    else if ((uint16_t)PrintVal == PrintVal) \
2493
2.08k
      CONCAT(printImmSVE, T)(PrintVal, O); \
2494
2.08k
    else { \
2495
1.21k
      SStream_concat(O, "%s", markup("<imm:")); \
2496
1.21k
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2497
1.21k
      SStream_concat0(O, markup(">")); \
2498
1.21k
    } \
2499
3.83k
  }
printSVELogicalImm_int16_t
Line
Count
Source
2478
958
  { \
2479
958
    AArch64_add_cs_detail_1( \
2480
958
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
958
      sizeof(T)); \
2482
958
    typedef T SignedT; \
2483
958
    typedef CONCATS(u, T) UnsignedT; \
2484
958
\
2485
958
    uint64_t Val = \
2486
958
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
958
    UnsignedT PrintVal = \
2488
958
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
958
\
2490
958
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
958
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
958
    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
958
  }
printSVELogicalImm_int32_t
Line
Count
Source
2478
1.49k
  { \
2479
1.49k
    AArch64_add_cs_detail_1( \
2480
1.49k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
1.49k
      sizeof(T)); \
2482
1.49k
    typedef T SignedT; \
2483
1.49k
    typedef CONCATS(u, T) UnsignedT; \
2484
1.49k
\
2485
1.49k
    uint64_t Val = \
2486
1.49k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
1.49k
    UnsignedT PrintVal = \
2488
1.49k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
1.49k
\
2490
1.49k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
1.49k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
1.49k
    else if ((uint16_t)PrintVal == PrintVal) \
2493
758
      CONCAT(printImmSVE, T)(PrintVal, O); \
2494
758
    else { \
2495
482
      SStream_concat(O, "%s", markup("<imm:")); \
2496
482
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2497
482
      SStream_concat0(O, markup(">")); \
2498
482
    } \
2499
1.49k
  }
printSVELogicalImm_int64_t
Line
Count
Source
2478
1.37k
  { \
2479
1.37k
    AArch64_add_cs_detail_1( \
2480
1.37k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2481
1.37k
      sizeof(T)); \
2482
1.37k
    typedef T SignedT; \
2483
1.37k
    typedef CONCATS(u, T) UnsignedT; \
2484
1.37k
\
2485
1.37k
    uint64_t Val = \
2486
1.37k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2487
1.37k
    UnsignedT PrintVal = \
2488
1.37k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2489
1.37k
\
2490
1.37k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2491
1.37k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2492
1.37k
    else if ((uint16_t)PrintVal == PrintVal) \
2493
1.32k
      CONCAT(printImmSVE, T)(PrintVal, O); \
2494
1.32k
    else { \
2495
728
      SStream_concat(O, "%s", markup("<imm:")); \
2496
728
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2497
728
      SStream_concat0(O, markup(">")); \
2498
728
    } \
2499
1.37k
  }
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.91k
  { \
2508
1.91k
    AArch64_add_cs_detail_1( \
2509
1.91k
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
1.91k
      Width); \
2511
1.91k
    unsigned Base; \
2512
1.91k
    switch (Width) { \
2513
475
    case 8: \
2514
475
      Base = AArch64_B0; \
2515
475
      break; \
2516
565
    case 16: \
2517
565
      Base = AArch64_H0; \
2518
565
      break; \
2519
263
    case 32: \
2520
263
      Base = AArch64_S0; \
2521
263
      break; \
2522
546
    case 64: \
2523
546
      Base = AArch64_D0; \
2524
546
      break; \
2525
67
    case 128: \
2526
67
      Base = AArch64_Q0; \
2527
67
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
1.91k
    } \
2531
1.91k
    unsigned Reg = \
2532
1.91k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
1.91k
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
1.91k
  }
printZPRasFPR_8
Line
Count
Source
2507
475
  { \
2508
475
    AArch64_add_cs_detail_1( \
2509
475
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
475
      Width); \
2511
475
    unsigned Base; \
2512
475
    switch (Width) { \
2513
475
    case 8: \
2514
475
      Base = AArch64_B0; \
2515
475
      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
475
    } \
2531
475
    unsigned Reg = \
2532
475
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
475
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
475
  }
printZPRasFPR_64
Line
Count
Source
2507
546
  { \
2508
546
    AArch64_add_cs_detail_1( \
2509
546
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
546
      Width); \
2511
546
    unsigned Base; \
2512
546
    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
546
    case 64: \
2523
546
      Base = AArch64_D0; \
2524
546
      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
546
    } \
2531
546
    unsigned Reg = \
2532
546
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
546
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
546
  }
printZPRasFPR_16
Line
Count
Source
2507
565
  { \
2508
565
    AArch64_add_cs_detail_1( \
2509
565
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
565
      Width); \
2511
565
    unsigned Base; \
2512
565
    switch (Width) { \
2513
0
    case 8: \
2514
0
      Base = AArch64_B0; \
2515
0
      break; \
2516
565
    case 16: \
2517
565
      Base = AArch64_H0; \
2518
565
      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
565
    } \
2531
565
    unsigned Reg = \
2532
565
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
565
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
565
  }
printZPRasFPR_32
Line
Count
Source
2507
263
  { \
2508
263
    AArch64_add_cs_detail_1( \
2509
263
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
263
      Width); \
2511
263
    unsigned Base; \
2512
263
    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
263
    case 32: \
2520
263
      Base = AArch64_S0; \
2521
263
      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
263
    } \
2531
263
    unsigned Reg = \
2532
263
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
263
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
263
  }
printZPRasFPR_128
Line
Count
Source
2507
67
  { \
2508
67
    AArch64_add_cs_detail_1( \
2509
67
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2510
67
      Width); \
2511
67
    unsigned Base; \
2512
67
    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
67
    case 128: \
2526
67
      Base = AArch64_Q0; \
2527
67
      break; \
2528
0
    default: \
2529
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2530
67
    } \
2531
67
    unsigned Reg = \
2532
67
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2533
67
    printRegName(O, Reg - AArch64_Z0 + Base); \
2534
67
  }
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.10k
  { \
2545
1.10k
    AArch64_add_cs_detail_2( \
2546
1.10k
      MI, \
2547
1.10k
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
1.10k
             ImmIs1), \
2549
1.10k
      OpNum, ImmIs0, ImmIs1); \
2550
1.10k
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
1.10k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
1.10k
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
1.10k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
1.10k
    unsigned Val = \
2555
1.10k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
1.10k
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
1.10k
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
1.10k
    SStream_concat0(O, markup(">")); \
2559
1.10k
  }
printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_one
Line
Count
Source
2544
520
  { \
2545
520
    AArch64_add_cs_detail_2( \
2546
520
      MI, \
2547
520
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
520
             ImmIs1), \
2549
520
      OpNum, ImmIs0, ImmIs1); \
2550
520
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
520
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
520
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
520
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
520
    unsigned Val = \
2555
520
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
520
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
520
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
520
    SStream_concat0(O, markup(">")); \
2559
520
  }
printExactFPImm_AArch64ExactFPImm_zero_AArch64ExactFPImm_one
Line
Count
Source
2544
221
  { \
2545
221
    AArch64_add_cs_detail_2( \
2546
221
      MI, \
2547
221
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
221
             ImmIs1), \
2549
221
      OpNum, ImmIs0, ImmIs1); \
2550
221
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
221
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
221
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
221
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
221
    unsigned Val = \
2555
221
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
221
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
221
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
221
    SStream_concat0(O, markup(">")); \
2559
221
  }
printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_two
Line
Count
Source
2544
360
  { \
2545
360
    AArch64_add_cs_detail_2( \
2546
360
      MI, \
2547
360
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2548
360
             ImmIs1), \
2549
360
      OpNum, ImmIs0, ImmIs1); \
2550
360
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2551
360
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2552
360
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2553
360
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2554
360
    unsigned Val = \
2555
360
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2556
360
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2557
360
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2558
360
    SStream_concat0(O, markup(">")); \
2559
360
  }
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.84k
{
2566
4.84k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64as32, OpNum);
2567
4.84k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2568
4.84k
  printRegName(O, getWRegFromXReg(Reg));
2569
4.84k
}
2570
2571
void printGPR64x8(MCInst *MI, unsigned OpNum, SStream *O)
2572
144
{
2573
144
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64x8, OpNum);
2574
144
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2575
144
  printRegName(O,
2576
144
         MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_x8sub_0));
2577
144
}
2578
2579
void printSyspXzrPair(MCInst *MI, unsigned OpNum, SStream *O)
2580
1.42k
{
2581
1.42k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SyspXzrPair, OpNum);
2582
1.42k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2583
2584
1.42k
  SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_NoRegAltName),
2585
1.42k
           ", ");
2586
1.42k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2587
1.42k
}
2588
2589
const char *AArch64_LLVM_getRegisterName(unsigned RegNo, unsigned AltIdx)
2590
220k
{
2591
220k
  return getRegisterName(RegNo, AltIdx);
2592
220k
}
2593
2594
void AArch64_LLVM_printInstruction(MCInst *MI, SStream *O,
2595
           void * /* MCRegisterInfo* */ info)
2596
374k
{
2597
374k
  printInst(MI, MI->address, "", O);
2598
374k
}