Coverage Report

Created: 2025-07-11 06:32

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