Coverage Report

Created: 2025-11-16 06:38

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