Coverage Report

Created: 2025-07-04 06:11

/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
293k
#define CONCAT(a, b) CONCAT_(a, b)
49
293k
#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
476k
{
81
476k
  SStream_concat(OS, "%s%s", markup("<reg:"),
82
476k
           getRegisterName(Reg, AArch64_NoRegAltName));
83
476k
  SStream_concat0(OS, markup(">"));
84
476k
}
85
86
void printRegNameAlt(SStream *OS, unsigned Reg, unsigned AltIdx)
87
98.6k
{
88
98.6k
  SStream_concat(OS, "%s%s", markup("<reg:"),
89
98.6k
           getRegisterName(Reg, AltIdx));
90
98.6k
  SStream_concat0(OS, markup(">"));
91
98.6k
}
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
231k
{
100
231k
  bool isAlias = false;
101
231k
  bool useAliasDetails = map_use_alias_details(MI);
102
231k
  map_set_fill_detail_ops(MI, useAliasDetails);
103
104
231k
  unsigned Opcode = MCInst_getOpcode(MI);
105
106
231k
  if (Opcode == AArch64_SYSxt) {
107
3.98k
    if (printSysAlias(MI, O)) {
108
1.28k
      isAlias = true;
109
1.28k
      MCInst_setIsAlias(MI, isAlias);
110
1.28k
      if (useAliasDetails)
111
1.28k
        return;
112
1.28k
    }
113
3.98k
  }
114
115
230k
  if (Opcode == AArch64_SYSPxt || Opcode == AArch64_SYSPxt_XZR) {
116
1.17k
    if (printSyspAlias(MI, O)) {
117
545
      isAlias = true;
118
545
      MCInst_setIsAlias(MI, isAlias);
119
545
      if (useAliasDetails)
120
545
        return;
121
545
    }
122
1.17k
  }
123
124
  // RPRFM overlaps PRFM (reg), so try to print it as RPRFM here.
125
229k
  if ((Opcode == AArch64_PRFMroX) || (Opcode == AArch64_PRFMroW)) {
126
232
    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
232
  }
133
134
  // SBFM/UBFM should print to a nicer aliased form if possible.
135
229k
  if (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri ||
136
229k
      Opcode == AArch64_UBFMXri || Opcode == AArch64_UBFMWri) {
137
2.53k
    MCOperand *Op0 = MCInst_getOperand(MI, (0));
138
2.53k
    MCOperand *Op1 = MCInst_getOperand(MI, (1));
139
2.53k
    MCOperand *Op2 = MCInst_getOperand(MI, (2));
140
2.53k
    MCOperand *Op3 = MCInst_getOperand(MI, (3));
141
142
2.53k
    bool IsSigned = (Opcode == AArch64_SBFMXri ||
143
2.53k
         Opcode == AArch64_SBFMWri);
144
2.53k
    bool Is64Bit = (Opcode == AArch64_SBFMXri ||
145
2.53k
        Opcode == AArch64_UBFMXri);
146
2.53k
    if (MCOperand_isImm(Op2) && MCOperand_getImm(Op2) == 0 &&
147
2.53k
        MCOperand_isImm(Op3)) {
148
1.45k
      const char *AsmMnemonic = NULL;
149
150
1.45k
      switch (MCOperand_getImm(Op3)) {
151
739
      default:
152
739
        break;
153
739
      case 7:
154
314
        if (IsSigned)
155
135
          AsmMnemonic = "sxtb";
156
179
        else if (!Is64Bit)
157
18
          AsmMnemonic = "uxtb";
158
314
        break;
159
314
      case 15:
160
314
        if (IsSigned)
161
59
          AsmMnemonic = "sxth";
162
255
        else if (!Is64Bit)
163
128
          AsmMnemonic = "uxth";
164
314
        break;
165
88
      case 31:
166
        // *xtw is only valid for signed 64-bit operations.
167
88
        if (Is64Bit && IsSigned)
168
62
          AsmMnemonic = "sxtw";
169
88
        break;
170
1.45k
      }
171
172
1.45k
      if (AsmMnemonic) {
173
402
        SStream_concat(O, "%s", AsmMnemonic);
174
402
        SStream_concat0(O, " ");
175
176
402
        printRegName(O, MCOperand_getReg(Op0));
177
402
        SStream_concat0(O, ", ");
178
402
        printRegName(O, getWRegFromXReg(
179
402
              MCOperand_getReg(Op1)));
180
402
        if (detail_is_set(MI) && useAliasDetails) {
181
402
          AArch64_set_detail_op_reg(
182
402
            MI, 0, MCOperand_getReg(Op0));
183
402
          AArch64_set_detail_op_reg(
184
402
            MI, 1,
185
402
            getWRegFromXReg(
186
402
              MCOperand_getReg(Op1)));
187
402
          if (strings_match(AsmMnemonic, "uxtb"))
188
18
            AArch64_get_detail_op(MI, -1)
189
18
              ->ext =
190
18
              AARCH64_EXT_UXTB;
191
384
          else if (strings_match(AsmMnemonic,
192
384
                     "sxtb"))
193
135
            AArch64_get_detail_op(MI, -1)
194
135
              ->ext =
195
135
              AARCH64_EXT_SXTB;
196
249
          else if (strings_match(AsmMnemonic,
197
249
                     "uxth"))
198
128
            AArch64_get_detail_op(MI, -1)
199
128
              ->ext =
200
128
              AARCH64_EXT_UXTH;
201
121
          else if (strings_match(AsmMnemonic,
202
121
                     "sxth"))
203
59
            AArch64_get_detail_op(MI, -1)
204
59
              ->ext =
205
59
              AARCH64_EXT_SXTH;
206
62
          else if (strings_match(AsmMnemonic,
207
62
                     "sxtw"))
208
62
            AArch64_get_detail_op(MI, -1)
209
62
              ->ext =
210
62
              AARCH64_EXT_SXTW;
211
0
          else
212
0
            AArch64_get_detail_op(MI, -1)
213
0
              ->ext =
214
0
              AARCH64_EXT_INVALID;
215
402
        }
216
402
        isAlias = true;
217
402
        MCInst_setIsAlias(MI, isAlias);
218
402
        if (useAliasDetails)
219
402
          return;
220
0
        else
221
0
          goto add_real_detail;
222
402
      }
223
1.45k
    }
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.13k
    if (MCOperand_isImm(Op2) && MCOperand_isImm(Op3)) {
229
2.13k
      const char *AsmMnemonic = NULL;
230
2.13k
      int shift = 0;
231
2.13k
      int64_t immr = MCOperand_getImm(Op2);
232
2.13k
      int64_t imms = MCOperand_getImm(Op3);
233
2.13k
      if (Opcode == AArch64_UBFMWri && imms != 0x1F &&
234
2.13k
          ((imms + 1) == immr)) {
235
94
        AsmMnemonic = "lsl";
236
94
        shift = 31 - imms;
237
2.03k
      } else if (Opcode == AArch64_UBFMXri && imms != 0x3f &&
238
2.03k
           ((imms + 1 == immr))) {
239
78
        AsmMnemonic = "lsl";
240
78
        shift = 63 - imms;
241
1.96k
      } else if (Opcode == AArch64_UBFMWri && imms == 0x1f) {
242
38
        AsmMnemonic = "lsr";
243
38
        shift = immr;
244
1.92k
      } else if (Opcode == AArch64_UBFMXri && imms == 0x3f) {
245
26
        AsmMnemonic = "lsr";
246
26
        shift = immr;
247
1.89k
      } else if (Opcode == AArch64_SBFMWri && imms == 0x1f) {
248
71
        AsmMnemonic = "asr";
249
71
        shift = immr;
250
1.82k
      } else if (Opcode == AArch64_SBFMXri && imms == 0x3f) {
251
465
        AsmMnemonic = "asr";
252
465
        shift = immr;
253
465
      }
254
2.13k
      if (AsmMnemonic) {
255
772
        SStream_concat(O, "%s", AsmMnemonic);
256
772
        SStream_concat0(O, " ");
257
258
772
        printRegName(O, MCOperand_getReg(Op0));
259
772
        SStream_concat0(O, ", ");
260
772
        printRegName(O, MCOperand_getReg(Op1));
261
772
        SStream_concat(O, "%s%s#%d", ", ",
262
772
                 markup("<imm:"), shift);
263
772
        SStream_concat0(O, markup(">"));
264
772
        if (detail_is_set(MI) && useAliasDetails) {
265
772
          AArch64_set_detail_op_reg(
266
772
            MI, 0, MCOperand_getReg(Op0));
267
772
          AArch64_set_detail_op_reg(
268
772
            MI, 1, MCOperand_getReg(Op1));
269
772
          if (strings_match(AsmMnemonic, "lsl"))
270
172
            AArch64_get_detail_op(MI, -1)
271
172
              ->shift.type =
272
172
              AARCH64_SFT_LSL;
273
600
          else if (strings_match(AsmMnemonic,
274
600
                     "lsr"))
275
64
            AArch64_get_detail_op(MI, -1)
276
64
              ->shift.type =
277
64
              AARCH64_SFT_LSR;
278
536
          else if (strings_match(AsmMnemonic,
279
536
                     "asr"))
280
536
            AArch64_get_detail_op(MI, -1)
281
536
              ->shift.type =
282
536
              AARCH64_SFT_ASR;
283
0
          else
284
0
            AArch64_get_detail_op(MI, -1)
285
0
              ->shift.type =
286
0
              AARCH64_SFT_INVALID;
287
772
          AArch64_get_detail_op(MI, -1)
288
772
            ->shift.value = shift;
289
772
        }
290
772
        isAlias = true;
291
772
        MCInst_setIsAlias(MI, isAlias);
292
772
        if (useAliasDetails)
293
772
          return;
294
0
        else
295
0
          goto add_real_detail;
296
772
      }
297
2.13k
    }
298
299
    // SBFIZ/UBFIZ aliases
300
1.36k
    if (MCOperand_getImm(Op2) > MCOperand_getImm(Op3)) {
301
501
      SStream_concat(O, "%s", (IsSigned ? "sbfiz" : "ubfiz"));
302
501
      SStream_concat0(O, " ");
303
304
501
      printRegName(O, MCOperand_getReg(Op0));
305
501
      SStream_concat0(O, ", ");
306
501
      printRegName(O, MCOperand_getReg(Op1));
307
501
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
308
501
      printUInt32Bang(O, (Is64Bit ? 64 : 32) -
309
501
               MCOperand_getImm(Op2));
310
501
      SStream_concat(O, "%s%s%s", markup(">"), ", ",
311
501
               markup("<imm:"));
312
501
      printInt64Bang(O, MCOperand_getImm(Op3) + 1);
313
501
      SStream_concat0(O, markup(">"));
314
501
      if (detail_is_set(MI) && useAliasDetails) {
315
501
        AArch64_set_detail_op_reg(
316
501
          MI, 0, MCOperand_getReg(Op0));
317
501
        AArch64_set_detail_op_reg(
318
501
          MI, 1, MCOperand_getReg(Op1));
319
501
        AArch64_set_detail_op_imm(
320
501
          MI, 2, AARCH64_OP_IMM,
321
501
          (Is64Bit ? 64 : 32) -
322
501
            MCOperand_getImm(Op2));
323
501
        AArch64_set_detail_op_imm(
324
501
          MI, 3, AARCH64_OP_IMM,
325
501
          MCOperand_getImm(Op3) + 1);
326
501
      }
327
501
      isAlias = true;
328
501
      MCInst_setIsAlias(MI, isAlias);
329
501
      if (useAliasDetails)
330
501
        return;
331
0
      else
332
0
        goto add_real_detail;
333
501
    }
334
335
    // Otherwise SBFX/UBFX is the preferred form
336
860
    SStream_concat(O, "%s", (IsSigned ? "sbfx" : "ubfx"));
337
860
    SStream_concat0(O, " ");
338
339
860
    printRegName(O, MCOperand_getReg(Op0));
340
860
    SStream_concat0(O, ", ");
341
860
    printRegName(O, MCOperand_getReg(Op1));
342
860
    SStream_concat(O, "%s%s", ", ", markup("<imm:"));
343
860
    printInt64Bang(O, MCOperand_getImm(Op2));
344
860
    SStream_concat(O, "%s%s%s", markup(">"), ", ", markup("<imm:"));
345
860
    printInt64Bang(O, MCOperand_getImm(Op3) -
346
860
            MCOperand_getImm(Op2) + 1);
347
860
    SStream_concat0(O, markup(">"));
348
860
    if (detail_is_set(MI) && useAliasDetails) {
349
860
      AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0));
350
860
      AArch64_set_detail_op_reg(MI, 1, MCOperand_getReg(Op1));
351
860
      AArch64_set_detail_op_imm(MI, 2, AARCH64_OP_IMM,
352
860
              MCOperand_getImm(Op2));
353
860
      AArch64_set_detail_op_imm(
354
860
        MI, 3, AARCH64_OP_IMM,
355
860
        MCOperand_getImm(Op3) - MCOperand_getImm(Op2) +
356
860
          1);
357
860
    }
358
860
    isAlias = true;
359
860
    MCInst_setIsAlias(MI, isAlias);
360
860
    if (useAliasDetails)
361
860
      return;
362
0
    else
363
0
      goto add_real_detail;
364
860
  }
365
366
227k
  if (Opcode == AArch64_BFMXri || Opcode == AArch64_BFMWri) {
367
753
    isAlias = true;
368
753
    MCInst_setIsAlias(MI, isAlias);
369
753
    MCOperand *Op0 = MCInst_getOperand(MI, (0)); // Op1 == Op0
370
753
    MCOperand *Op2 = MCInst_getOperand(MI, (2));
371
753
    int ImmR = MCOperand_getImm(MCInst_getOperand(MI, (3)));
372
753
    int ImmS = MCOperand_getImm(MCInst_getOperand(MI, (4)));
373
374
753
    if ((MCOperand_getReg(Op2) == AArch64_WZR ||
375
753
         MCOperand_getReg(Op2) == AArch64_XZR) &&
376
753
        (ImmR == 0 || ImmS < ImmR) &&
377
753
        (AArch64_getFeatureBits(MI->csh->mode,
378
219
              AArch64_FeatureAll) ||
379
219
         AArch64_getFeatureBits(MI->csh->mode,
380
219
              AArch64_HasV8_2aOps))) {
381
      // BFC takes precedence over its entire range, sligtly differently
382
      // to BFI.
383
219
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
384
219
      int LSB = (BitWidth - ImmR) % BitWidth;
385
219
      int Width = ImmS + 1;
386
387
219
      SStream_concat0(O, "bfc ");
388
219
      printRegName(O, MCOperand_getReg(Op0));
389
219
      SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"),
390
219
               LSB);
391
219
      SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
392
219
               markup("<imm:"), Width);
393
219
      SStream_concat0(O, markup(">"));
394
219
      if (detail_is_set(MI) && useAliasDetails) {
395
219
        AArch64_set_detail_op_reg(
396
219
          MI, 0, MCOperand_getReg(Op0));
397
219
        AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM,
398
219
                LSB);
399
219
        AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM,
400
219
                Width);
401
219
      }
402
403
219
      if (useAliasDetails)
404
219
        return;
405
0
      else
406
0
        goto add_real_detail;
407
534
    } else if (ImmS < ImmR) {
408
      // BFI alias
409
286
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
410
286
      int LSB = (BitWidth - ImmR) % BitWidth;
411
286
      int Width = ImmS + 1;
412
413
286
      SStream_concat0(O, "bfi ");
414
286
      printRegName(O, MCOperand_getReg(Op0));
415
286
      SStream_concat0(O, ", ");
416
286
      printRegName(O, MCOperand_getReg(Op2));
417
286
      SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"),
418
286
               LSB);
419
286
      SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
420
286
               markup("<imm:"), Width);
421
286
      SStream_concat0(O, markup(">"));
422
286
      if (detail_is_set(MI) && useAliasDetails) {
423
286
        AArch64_set_detail_op_reg(
424
286
          MI, 0, MCOperand_getReg(Op0));
425
286
        AArch64_set_detail_op_reg(
426
286
          MI, 2, MCOperand_getReg(Op2));
427
286
        AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM,
428
286
                LSB);
429
286
        AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM,
430
286
                Width);
431
286
      }
432
286
      if (useAliasDetails)
433
286
        return;
434
0
      else
435
0
        goto add_real_detail;
436
286
    }
437
438
248
    int LSB = ImmR;
439
248
    int Width = ImmS - ImmR + 1;
440
    // Otherwise BFXIL the preferred form
441
248
    SStream_concat0(O, "bfxil ");
442
248
    printRegName(O, MCOperand_getReg(Op0));
443
248
    SStream_concat0(O, ", ");
444
248
    printRegName(O, MCOperand_getReg(Op2));
445
248
    SStream_concat(O, "%s%s#%d", ", ", markup("<imm:"), LSB);
446
248
    SStream_concat(O, "%s%s%s#%d", markup(">"), ", ",
447
248
             markup("<imm:"), Width);
448
248
    SStream_concat0(O, markup(">"));
449
248
    if (detail_is_set(MI) && useAliasDetails) {
450
248
      AArch64_set_detail_op_reg(MI, 0, MCOperand_getReg(Op0));
451
248
      AArch64_set_detail_op_reg(MI, 2, MCOperand_getReg(Op2));
452
248
      AArch64_set_detail_op_imm(MI, 3, AARCH64_OP_IMM, LSB);
453
248
      AArch64_set_detail_op_imm(MI, 4, AARCH64_OP_IMM, Width);
454
248
    }
455
248
    if (useAliasDetails)
456
248
      return;
457
248
  }
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
226k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi ||
463
226k
       Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
464
226k
      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
226k
  if ((Opcode == AArch64_MOVKXi || Opcode == AArch64_MOVKWi) &&
472
226k
      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
226k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi) &&
485
226k
      MCOperand_isImm(MCInst_getOperand(MI, (1))) &&
486
226k
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
487
767
    int RegWidth = Opcode == AArch64_MOVZXi ? 64 : 32;
488
767
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2)));
489
767
    uint64_t Value =
490
767
      (uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1)))
491
767
      << Shift;
492
493
767
    if (AArch64_AM_isMOVZMovAlias(
494
767
          Value, Shift, Opcode == AArch64_MOVZXi ? 64 : 32)) {
495
743
      isAlias = true;
496
743
      MCInst_setIsAlias(MI, isAlias);
497
743
      SStream_concat0(O, "mov ");
498
743
      printRegName(O, MCOperand_getReg(
499
743
            MCInst_getOperand(MI, (0))));
500
743
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
501
743
      printInt64Bang(O, SignExtend64(Value, RegWidth));
502
743
      SStream_concat0(O, markup(">"));
503
743
      if (detail_is_set(MI) && useAliasDetails) {
504
743
        AArch64_set_detail_op_reg(
505
743
          MI, 0, MCInst_getOpVal(MI, 0));
506
743
        AArch64_set_detail_op_imm(
507
743
          MI, 1, AARCH64_OP_IMM,
508
743
          SignExtend64(Value, RegWidth));
509
743
      }
510
743
      if (useAliasDetails)
511
743
        return;
512
743
    }
513
767
  }
514
515
225k
  if ((Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
516
225k
      MCOperand_isImm(MCInst_getOperand(MI, (1))) &&
517
225k
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
518
659
    int RegWidth = Opcode == AArch64_MOVNXi ? 64 : 32;
519
659
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, (2)));
520
659
    uint64_t Value =
521
659
      ~((uint64_t)MCOperand_getImm(MCInst_getOperand(MI, (1)))
522
659
        << Shift);
523
659
    if (RegWidth == 32)
524
93
      Value = Value & 0xffffffff;
525
526
659
    if (AArch64_AM_isMOVNMovAlias(Value, Shift, RegWidth)) {
527
588
      isAlias = true;
528
588
      MCInst_setIsAlias(MI, isAlias);
529
588
      SStream_concat0(O, "mov ");
530
588
      printRegName(O, MCOperand_getReg(
531
588
            MCInst_getOperand(MI, (0))));
532
588
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
533
588
      printInt64Bang(O, SignExtend64(Value, RegWidth));
534
588
      SStream_concat0(O, markup(">"));
535
588
      if (detail_is_set(MI) && useAliasDetails) {
536
588
        AArch64_set_detail_op_reg(
537
588
          MI, 0, MCInst_getOpVal(MI, 0));
538
588
        AArch64_set_detail_op_imm(
539
588
          MI, 1, AARCH64_OP_IMM,
540
588
          SignExtend64(Value, RegWidth));
541
588
      }
542
588
      if (useAliasDetails)
543
588
        return;
544
588
    }
545
659
  }
546
547
225k
  if ((Opcode == AArch64_ORRXri || Opcode == AArch64_ORRWri) &&
548
225k
      (MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_XZR ||
549
2.26k
       MCOperand_getReg(MCInst_getOperand(MI, (1))) == AArch64_WZR) &&
550
225k
      MCOperand_isImm(MCInst_getOperand(MI, (2)))) {
551
1.59k
    int RegWidth = Opcode == AArch64_ORRXri ? 64 : 32;
552
1.59k
    uint64_t Value = AArch64_AM_decodeLogicalImmediate(
553
1.59k
      MCOperand_getImm(MCInst_getOperand(MI, (2))), RegWidth);
554
1.59k
    if (!AArch64_AM_isAnyMOVWMovAlias(Value, RegWidth)) {
555
757
      isAlias = true;
556
757
      MCInst_setIsAlias(MI, isAlias);
557
757
      SStream_concat0(O, "mov ");
558
757
      printRegName(O, MCOperand_getReg(
559
757
            MCInst_getOperand(MI, (0))));
560
757
      SStream_concat(O, "%s%s", ", ", markup("<imm:"));
561
757
      printInt64Bang(O, SignExtend64(Value, RegWidth));
562
757
      SStream_concat0(O, markup(">"));
563
757
      if (detail_is_set(MI) && useAliasDetails) {
564
757
        AArch64_set_detail_op_reg(
565
757
          MI, 0, MCInst_getOpVal(MI, 0));
566
757
        AArch64_set_detail_op_imm(
567
757
          MI, 2, AARCH64_OP_IMM,
568
757
          SignExtend64(Value, RegWidth));
569
757
      }
570
757
      if (useAliasDetails)
571
757
        return;
572
757
    }
573
1.59k
  }
574
575
224k
  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
224k
  if (!isAlias)
590
224k
    isAlias |= printAliasInstr(MI, Address, O);
591
592
224k
add_real_detail:
593
224k
  MCInst_setIsAlias(MI, isAlias);
594
595
224k
  if (!isAlias || !useAliasDetails) {
596
201k
    map_set_fill_detail_ops(MI, !(isAlias && useAliasDetails));
597
201k
    if (isAlias)
598
0
      SStream_Close(O);
599
201k
    printInstruction(MI, Address, O);
600
201k
    if (isAlias)
601
0
      SStream_Open(O);
602
201k
  }
603
224k
}
604
605
bool printRangePrefetchAlias(MCInst *MI, SStream *O, const char *Annot)
606
232
{
607
232
  unsigned Opcode = MCInst_getOpcode(MI);
608
609
232
#ifndef NDEBUG
610
611
232
#endif
612
613
232
  unsigned PRFOp = MCOperand_getImm(MCInst_getOperand(MI, (0)));
614
232
  unsigned Mask = 0x18; // 0b11000
615
232
  if ((PRFOp & Mask) != Mask)
616
232
    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
232
}
653
654
bool printSysAlias(MCInst *MI, SStream *O)
655
3.98k
{
656
3.98k
  MCOperand *Op1 = MCInst_getOperand(MI, (0));
657
3.98k
  MCOperand *Cn = MCInst_getOperand(MI, (1));
658
3.98k
  MCOperand *Cm = MCInst_getOperand(MI, (2));
659
3.98k
  MCOperand *Op2 = MCInst_getOperand(MI, (3));
660
661
3.98k
  unsigned Op1Val = MCOperand_getImm(Op1);
662
3.98k
  unsigned CnVal = MCOperand_getImm(Cn);
663
3.98k
  unsigned CmVal = MCOperand_getImm(Cm);
664
3.98k
  unsigned Op2Val = MCOperand_getImm(Op2);
665
666
3.98k
  uint16_t Encoding = Op2Val;
667
3.98k
  Encoding |= CmVal << 3;
668
3.98k
  Encoding |= CnVal << 7;
669
3.98k
  Encoding |= Op1Val << 11;
670
671
3.98k
  bool NeedsReg;
672
3.98k
  const char *Ins;
673
3.98k
  const char *Name;
674
675
3.98k
  if (CnVal == 7) {
676
2.94k
    switch (CmVal) {
677
95
    default:
678
95
      return false;
679
    // Maybe IC, maybe Prediction Restriction
680
468
    case 1:
681
468
      switch (Op1Val) {
682
34
      default:
683
34
        return false;
684
329
      case 0:
685
329
        goto Search_IC;
686
105
      case 3:
687
105
        goto Search_PRCTX;
688
468
      }
689
    // Prediction Restriction aliases
690
412
    case 3: {
691
517
Search_PRCTX:
692
517
      if (Op1Val != 3 || CnVal != 7 || CmVal != 3)
693
115
        return false;
694
695
402
      unsigned int Requires =
696
402
        Op2Val == 6 ? AArch64_FeatureSPECRES2 :
697
402
                AArch64_FeaturePredRes;
698
402
      if (!(AArch64_getFeatureBits(MI->csh->mode,
699
402
                 AArch64_FeatureAll) ||
700
402
            AArch64_getFeatureBits(MI->csh->mode, Requires)))
701
0
        return false;
702
703
402
      NeedsReg = true;
704
402
      switch (Op2Val) {
705
230
      default:
706
230
        return false;
707
96
      case 4:
708
96
        Ins = "cfp ";
709
96
        break;
710
8
      case 5:
711
8
        Ins = "dvp ";
712
8
        break;
713
63
      case 6:
714
63
        Ins = "cosp ";
715
63
        break;
716
5
      case 7:
717
5
        Ins = "cpp ";
718
5
        break;
719
402
      }
720
172
      Name = "RCTX";
721
172
    } break;
722
    // IC aliases
723
19
    case 5: {
724
348
Search_IC: {
725
348
  const AArch64IC_IC *IC = AArch64IC_lookupICByEncoding(Encoding);
726
348
  if (!IC ||
727
348
      !AArch64_testFeatureList(MI->csh->mode, IC->FeaturesRequired))
728
272
    return false;
729
76
  if (detail_is_set(MI)) {
730
76
    aarch64_sysop sysop = { 0 };
731
76
    sysop.reg = IC->SysReg;
732
76
    sysop.sub_type = AARCH64_OP_IC;
733
76
    AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
734
76
    AArch64_get_detail_op(MI, 0)->sysop = sysop;
735
76
    AArch64_inc_op_count(MI);
736
76
  }
737
738
76
  NeedsReg = IC->NeedsReg;
739
76
  Ins = "ic ";
740
76
  Name = IC->Name;
741
76
}
742
76
    } break;
743
    // DC aliases
744
327
    case 4:
745
348
    case 6:
746
363
    case 10:
747
373
    case 11:
748
445
    case 12:
749
607
    case 13:
750
617
    case 14: {
751
617
      const AArch64DC_DC *DC =
752
617
        AArch64DC_lookupDCByEncoding(Encoding);
753
617
      if (!DC || !AArch64_testFeatureList(
754
157
             MI->csh->mode, DC->FeaturesRequired))
755
460
        return false;
756
157
      if (detail_is_set(MI)) {
757
157
        aarch64_sysop sysop = { 0 };
758
157
        sysop.alias = DC->SysAlias;
759
157
        sysop.sub_type = AARCH64_OP_DC;
760
157
        AArch64_get_detail_op(MI, 0)->type =
761
157
          AARCH64_OP_SYSALIAS;
762
157
        AArch64_get_detail_op(MI, 0)->sysop = sysop;
763
157
        AArch64_inc_op_count(MI);
764
157
      }
765
766
157
      NeedsReg = true;
767
157
      Ins = "dc ";
768
157
      Name = DC->Name;
769
157
    } break;
770
    // AT aliases
771
440
    case 8:
772
1.33k
    case 9: {
773
1.33k
      const AArch64AT_AT *AT =
774
1.33k
        AArch64AT_lookupATByEncoding(Encoding);
775
1.33k
      if (!AT || !AArch64_testFeatureList(
776
610
             MI->csh->mode, AT->FeaturesRequired))
777
727
        return false;
778
779
610
      if (detail_is_set(MI)) {
780
610
        aarch64_sysop sysop = { 0 };
781
610
        sysop.alias = AT->SysAlias;
782
610
        sysop.sub_type = AARCH64_OP_AT;
783
610
        AArch64_get_detail_op(MI, 0)->type =
784
610
          AARCH64_OP_SYSALIAS;
785
610
        AArch64_get_detail_op(MI, 0)->sysop = sysop;
786
610
        AArch64_inc_op_count(MI);
787
610
      }
788
610
      NeedsReg = true;
789
610
      Ins = "at ";
790
610
      Name = AT->Name;
791
610
    } break;
792
2.94k
    }
793
2.94k
  } else if (CnVal == 8 || CnVal == 9) {
794
    // TLBI aliases
795
687
    const AArch64TLBI_TLBI *TLBI =
796
687
      AArch64TLBI_lookupTLBIByEncoding(Encoding);
797
687
    if (!TLBI || !AArch64_testFeatureList(MI->csh->mode,
798
265
                  TLBI->FeaturesRequired))
799
422
      return false;
800
801
265
    if (detail_is_set(MI)) {
802
265
      aarch64_sysop sysop = { 0 };
803
265
      sysop.reg = TLBI->SysReg;
804
265
      sysop.sub_type = AARCH64_OP_TLBI;
805
265
      AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
806
265
      AArch64_get_detail_op(MI, 0)->sysop = sysop;
807
265
      AArch64_inc_op_count(MI);
808
265
    }
809
265
    NeedsReg = TLBI->NeedsReg;
810
265
    Ins = "tlbi ";
811
265
    Name = TLBI->Name;
812
265
  } else
813
351
    return false;
814
815
2.56k
#define TMP_STR_LEN 32
816
1.28k
  char Str[TMP_STR_LEN] = { 0 };
817
1.28k
  append_to_str_lower(Str, TMP_STR_LEN, Ins);
818
1.28k
  append_to_str_lower(Str, TMP_STR_LEN, Name);
819
1.28k
#undef TMP_STR_LEN
820
821
1.28k
  SStream_concat1(O, ' ');
822
1.28k
  SStream_concat0(O, Str);
823
1.28k
  if (NeedsReg) {
824
1.04k
    SStream_concat0(O, ", ");
825
1.04k
    printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (4))));
826
1.04k
    AArch64_set_detail_op_reg(MI, 4, MCInst_getOpVal(MI, 4));
827
1.04k
  }
828
829
1.28k
  return true;
830
3.98k
}
831
832
bool printSyspAlias(MCInst *MI, SStream *O)
833
1.17k
{
834
1.17k
  MCOperand *Op1 = MCInst_getOperand(MI, (0));
835
1.17k
  MCOperand *Cn = MCInst_getOperand(MI, (1));
836
1.17k
  MCOperand *Cm = MCInst_getOperand(MI, (2));
837
1.17k
  MCOperand *Op2 = MCInst_getOperand(MI, (3));
838
839
1.17k
  unsigned Op1Val = MCOperand_getImm(Op1);
840
1.17k
  unsigned CnVal = MCOperand_getImm(Cn);
841
1.17k
  unsigned CmVal = MCOperand_getImm(Cm);
842
1.17k
  unsigned Op2Val = MCOperand_getImm(Op2);
843
844
1.17k
  uint16_t Encoding = Op2Val;
845
1.17k
  Encoding |= CmVal << 3;
846
1.17k
  Encoding |= CnVal << 7;
847
1.17k
  Encoding |= Op1Val << 11;
848
849
1.17k
  const char *Ins;
850
1.17k
  const char *Name;
851
852
1.17k
  if (CnVal == 8 || CnVal == 9) {
853
    // TLBIP aliases
854
855
750
    if (CnVal == 9) {
856
240
      if (!AArch64_getFeatureBits(MI->csh->mode,
857
240
                AArch64_FeatureAll) ||
858
240
          !AArch64_getFeatureBits(MI->csh->mode,
859
240
                AArch64_FeatureXS))
860
0
        return false;
861
240
      Encoding &= ~(1 << 7);
862
240
    }
863
864
750
    const AArch64TLBI_TLBI *TLBI =
865
750
      AArch64TLBI_lookupTLBIByEncoding(Encoding);
866
750
    if (!TLBI || !AArch64_testFeatureList(MI->csh->mode,
867
545
                  TLBI->FeaturesRequired))
868
205
      return false;
869
870
545
    if (detail_is_set(MI)) {
871
545
      aarch64_sysop sysop = { 0 };
872
545
      sysop.reg = TLBI->SysReg;
873
545
      sysop.sub_type = AARCH64_OP_TLBI;
874
545
      AArch64_get_detail_op(MI, 0)->type = AARCH64_OP_SYSREG;
875
545
      AArch64_get_detail_op(MI, 0)->sysop = sysop;
876
545
      AArch64_inc_op_count(MI);
877
545
    }
878
545
    Ins = "tlbip ";
879
545
    Name = TLBI->Name;
880
545
  } else
881
426
    return false;
882
883
1.31k
#define TMP_STR_LEN 32
884
545
  char Str[TMP_STR_LEN] = { 0 };
885
545
  append_to_str_lower(Str, TMP_STR_LEN, Ins);
886
545
  append_to_str_lower(Str, TMP_STR_LEN, Name);
887
888
545
  if (CnVal == 9) {
889
223
    append_to_str_lower(Str, TMP_STR_LEN, "nxs");
890
223
  }
891
545
#undef TMP_STR_LEN
892
893
545
  SStream_concat1(O, ' ');
894
545
  SStream_concat0(O, Str);
895
545
  SStream_concat0(O, ", ");
896
545
  if (MCOperand_getReg(MCInst_getOperand(MI, (4))) == AArch64_XZR)
897
275
    printSyspXzrPair(MI, 4, O);
898
270
  else
899
270
    CONCAT(printGPRSeqPairsClassOperand, 64)(MI, 4, O);
900
901
545
  return true;
902
1.17k
}
903
904
#define DEFINE_printMatrix(EltSize) \
905
  void CONCAT(printMatrix, EltSize)(MCInst * MI, unsigned OpNum, \
906
            SStream *O) \
907
6.97k
  { \
908
6.97k
    AArch64_add_cs_detail_1( \
909
6.97k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
910
6.97k
      EltSize); \
911
6.97k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
912
6.97k
\
913
6.97k
    printRegName(O, MCOperand_getReg(RegOp)); \
914
6.97k
    switch (EltSize) { \
915
59
    case 0: \
916
59
      break; \
917
0
    case 8: \
918
0
      SStream_concat0(O, ".b"); \
919
0
      break; \
920
1.96k
    case 16: \
921
1.96k
      SStream_concat0(O, ".h"); \
922
1.96k
      break; \
923
3.18k
    case 32: \
924
3.18k
      SStream_concat0(O, ".s"); \
925
3.18k
      break; \
926
1.77k
    case 64: \
927
1.77k
      SStream_concat0(O, ".d"); \
928
1.77k
      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
6.97k
    } \
935
6.97k
  }
printMatrix_64
Line
Count
Source
907
1.77k
  { \
908
1.77k
    AArch64_add_cs_detail_1( \
909
1.77k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
910
1.77k
      EltSize); \
911
1.77k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
912
1.77k
\
913
1.77k
    printRegName(O, MCOperand_getReg(RegOp)); \
914
1.77k
    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
1.77k
    case 64: \
927
1.77k
      SStream_concat0(O, ".d"); \
928
1.77k
      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
1.77k
    } \
935
1.77k
  }
printMatrix_32
Line
Count
Source
907
3.18k
  { \
908
3.18k
    AArch64_add_cs_detail_1( \
909
3.18k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
910
3.18k
      EltSize); \
911
3.18k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
912
3.18k
\
913
3.18k
    printRegName(O, MCOperand_getReg(RegOp)); \
914
3.18k
    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
3.18k
    case 32: \
924
3.18k
      SStream_concat0(O, ".s"); \
925
3.18k
      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.18k
    } \
935
3.18k
  }
printMatrix_16
Line
Count
Source
907
1.96k
  { \
908
1.96k
    AArch64_add_cs_detail_1( \
909
1.96k
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
910
1.96k
      EltSize); \
911
1.96k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
912
1.96k
\
913
1.96k
    printRegName(O, MCOperand_getReg(RegOp)); \
914
1.96k
    switch (EltSize) { \
915
0
    case 0: \
916
0
      break; \
917
0
    case 8: \
918
0
      SStream_concat0(O, ".b"); \
919
0
      break; \
920
1.96k
    case 16: \
921
1.96k
      SStream_concat0(O, ".h"); \
922
1.96k
      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
1.96k
    } \
935
1.96k
  }
printMatrix_0
Line
Count
Source
907
59
  { \
908
59
    AArch64_add_cs_detail_1( \
909
59
      MI, CONCAT(AArch64_OP_GROUP_Matrix, EltSize), OpNum, \
910
59
      EltSize); \
911
59
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
912
59
\
913
59
    printRegName(O, MCOperand_getReg(RegOp)); \
914
59
    switch (EltSize) { \
915
59
    case 0: \
916
59
      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
59
    } \
935
59
  }
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.15k
  { \
945
5.15k
    AArch64_add_cs_detail_1( \
946
5.15k
      MI, \
947
5.15k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
948
5.15k
      OpNum, IsVertical); \
949
5.15k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
950
5.15k
\
951
5.15k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
952
5.15k
                  AArch64_NoRegAltName); \
953
5.15k
\
954
5.15k
    unsigned buf_len = strlen(RegName) + 1; \
955
5.15k
    char *Base = cs_mem_calloc(1, buf_len); \
956
5.15k
    memcpy(Base, RegName, buf_len); \
957
5.15k
    char *Dot = strchr(Base, '.'); \
958
5.15k
    if (!Dot) { \
959
0
      SStream_concat0(O, RegName); \
960
0
      return; \
961
0
    } \
962
5.15k
    *Dot = '\0'; /* Split string */ \
963
5.15k
    char *Suffix = Dot + 1; \
964
5.15k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
965
5.15k
    SStream_concat1(O, '.'); \
966
5.15k
    SStream_concat0(O, Suffix); \
967
5.15k
    cs_mem_free(Base); \
968
5.15k
  }
printMatrixTileVector_0
Line
Count
Source
944
1.76k
  { \
945
1.76k
    AArch64_add_cs_detail_1( \
946
1.76k
      MI, \
947
1.76k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
948
1.76k
      OpNum, IsVertical); \
949
1.76k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
950
1.76k
\
951
1.76k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
952
1.76k
                  AArch64_NoRegAltName); \
953
1.76k
\
954
1.76k
    unsigned buf_len = strlen(RegName) + 1; \
955
1.76k
    char *Base = cs_mem_calloc(1, buf_len); \
956
1.76k
    memcpy(Base, RegName, buf_len); \
957
1.76k
    char *Dot = strchr(Base, '.'); \
958
1.76k
    if (!Dot) { \
959
0
      SStream_concat0(O, RegName); \
960
0
      return; \
961
0
    } \
962
1.76k
    *Dot = '\0'; /* Split string */ \
963
1.76k
    char *Suffix = Dot + 1; \
964
1.76k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
965
1.76k
    SStream_concat1(O, '.'); \
966
1.76k
    SStream_concat0(O, Suffix); \
967
1.76k
    cs_mem_free(Base); \
968
1.76k
  }
printMatrixTileVector_1
Line
Count
Source
944
3.38k
  { \
945
3.38k
    AArch64_add_cs_detail_1( \
946
3.38k
      MI, \
947
3.38k
      CONCAT(AArch64_OP_GROUP_MatrixTileVector, IsVertical), \
948
3.38k
      OpNum, IsVertical); \
949
3.38k
    MCOperand *RegOp = MCInst_getOperand(MI, (OpNum)); \
950
3.38k
\
951
3.38k
    const char *RegName = getRegisterName(MCOperand_getReg(RegOp), \
952
3.38k
                  AArch64_NoRegAltName); \
953
3.38k
\
954
3.38k
    unsigned buf_len = strlen(RegName) + 1; \
955
3.38k
    char *Base = cs_mem_calloc(1, buf_len); \
956
3.38k
    memcpy(Base, RegName, buf_len); \
957
3.38k
    char *Dot = strchr(Base, '.'); \
958
3.38k
    if (!Dot) { \
959
0
      SStream_concat0(O, RegName); \
960
0
      return; \
961
0
    } \
962
3.38k
    *Dot = '\0'; /* Split string */ \
963
3.38k
    char *Suffix = Dot + 1; \
964
3.38k
    SStream_concat(O, "%s%s", Base, (IsVertical ? "v" : "h")); \
965
3.38k
    SStream_concat1(O, '.'); \
966
3.38k
    SStream_concat0(O, Suffix); \
967
3.38k
    cs_mem_free(Base); \
968
3.38k
  }
969
DEFINE_printMatrixTileVector(0);
970
DEFINE_printMatrixTileVector(1);
971
972
void printMatrixTile(MCInst *MI, unsigned OpNum, SStream *O)
973
1.59k
{
974
1.59k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTile, OpNum);
975
1.59k
  MCOperand *RegOp = MCInst_getOperand(MI, (OpNum));
976
977
1.59k
  printRegName(O, MCOperand_getReg(RegOp));
978
1.59k
}
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
303k
{
993
303k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Operand, OpNo);
994
303k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
995
303k
  if (MCOperand_isReg(Op)) {
996
258k
    unsigned Reg = MCOperand_getReg(Op);
997
258k
    printRegName(O, Reg);
998
258k
  } else if (MCOperand_isImm(Op)) {
999
44.7k
    Op = MCInst_getOperand(MI, (OpNo));
1000
44.7k
    SStream_concat(O, "%s", markup("<imm:"));
1001
44.7k
    printInt64Bang(O, MCOperand_getImm(Op));
1002
44.7k
    SStream_concat0(O, markup(">"));
1003
44.7k
  } else {
1004
0
    printUInt64Bang(O, MCInst_getOpVal(MI, OpNo));
1005
0
  }
1006
303k
}
1007
1008
void printImm(MCInst *MI, unsigned OpNo, SStream *O)
1009
3.19k
{
1010
3.19k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Imm, OpNo);
1011
3.19k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1012
3.19k
  SStream_concat(O, "%s", markup("<imm:"));
1013
3.19k
  printInt64Bang(O, MCOperand_getImm(Op));
1014
3.19k
  SStream_concat0(O, markup(">"));
1015
3.19k
}
1016
1017
void printImmHex(MCInst *MI, unsigned OpNo, SStream *O)
1018
55
{
1019
55
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ImmHex, OpNo);
1020
55
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1021
55
  SStream_concat(O, "%s", markup("<imm:"));
1022
55
  printInt64Bang(O, MCOperand_getImm(Op));
1023
55
  SStream_concat0(O, markup(">"));
1024
55
}
1025
1026
#define DEFINE_printSImm(Size) \
1027
  void CONCAT(printSImm, Size)(MCInst * MI, unsigned OpNo, SStream *O) \
1028
823
  { \
1029
823
    AArch64_add_cs_detail_1( \
1030
823
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1031
823
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1032
823
    if (Size == 8) { \
1033
401
      SStream_concat(O, "%s", markup("<imm:")); \
1034
401
      printInt32Bang(O, MCOperand_getImm(Op)); \
1035
401
      SStream_concat0(O, markup(">")); \
1036
422
    } else if (Size == 16) { \
1037
422
      SStream_concat(O, "%s", markup("<imm:")); \
1038
422
      printInt32Bang(O, MCOperand_getImm(Op)); \
1039
422
      SStream_concat0(O, markup(">")); \
1040
422
    } 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
823
  }
printSImm_16
Line
Count
Source
1028
422
  { \
1029
422
    AArch64_add_cs_detail_1( \
1030
422
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1031
422
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1032
422
    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
422
    } else if (Size == 16) { \
1037
422
      SStream_concat(O, "%s", markup("<imm:")); \
1038
422
      printInt32Bang(O, MCOperand_getImm(Op)); \
1039
422
      SStream_concat0(O, markup(">")); \
1040
422
    } 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
422
  }
printSImm_8
Line
Count
Source
1028
401
  { \
1029
401
    AArch64_add_cs_detail_1( \
1030
401
      MI, CONCAT(AArch64_OP_GROUP_SImm, Size), OpNo, Size); \
1031
401
    MCOperand *Op = MCInst_getOperand(MI, (OpNo)); \
1032
401
    if (Size == 8) { \
1033
401
      SStream_concat(O, "%s", markup("<imm:")); \
1034
401
      printInt32Bang(O, MCOperand_getImm(Op)); \
1035
401
      SStream_concat0(O, markup(">")); \
1036
401
    } 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
401
  }
1046
DEFINE_printSImm(16);
1047
DEFINE_printSImm(8);
1048
1049
void printPostIncOperand(MCInst *MI, unsigned OpNo, unsigned Imm, SStream *O)
1050
8.35k
{
1051
8.35k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1052
8.35k
  if (MCOperand_isReg(Op)) {
1053
8.35k
    unsigned Reg = MCOperand_getReg(Op);
1054
8.35k
    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
8.35k
      printRegName(O, Reg);
1060
8.35k
  } else
1061
0
    CS_ASSERT_RET(0 && "unknown operand kind in printPostIncOperand64");
1062
8.35k
}
1063
1064
void printVRegOperand(MCInst *MI, unsigned OpNo, SStream *O)
1065
44.0k
{
1066
44.0k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_VRegOperand, OpNo);
1067
44.0k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1068
1069
44.0k
  unsigned Reg = MCOperand_getReg(Op);
1070
44.0k
  printRegNameAlt(O, Reg, AArch64_vreg);
1071
44.0k
}
1072
1073
void printSysCROperand(MCInst *MI, unsigned OpNo, SStream *O)
1074
6.82k
{
1075
6.82k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SysCROperand, OpNo);
1076
6.82k
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
1077
1078
6.82k
  SStream_concat(O, "%s", "c");
1079
6.82k
  printUInt32(O, MCOperand_getImm(Op));
1080
6.82k
  SStream_concat1(O, '\0');
1081
6.82k
}
1082
1083
void printAddSubImm(MCInst *MI, unsigned OpNum, SStream *O)
1084
3.16k
{
1085
3.16k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AddSubImm, OpNum);
1086
3.16k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1087
3.16k
  if (MCOperand_isImm(MO)) {
1088
3.16k
    unsigned Val = (MCOperand_getImm(MO) & 0xfff);
1089
1090
3.16k
    unsigned Shift = AArch64_AM_getShiftValue(
1091
3.16k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))));
1092
3.16k
    SStream_concat(O, "%s", markup("<imm:"));
1093
3.16k
    printUInt32Bang(O, (Val));
1094
3.16k
    SStream_concat0(O, markup(">"));
1095
3.16k
    if (Shift != 0) {
1096
2.04k
      printShifter(MI, OpNum + 1, O);
1097
2.04k
    }
1098
3.16k
  } else {
1099
0
    printShifter(MI, OpNum + 1, O);
1100
0
  }
1101
3.16k
}
1102
1103
#define DEFINE_printLogicalImm(T) \
1104
  void CONCAT(printLogicalImm, T)(MCInst * MI, unsigned OpNum, \
1105
          SStream *O) \
1106
6.62k
  { \
1107
6.62k
    AArch64_add_cs_detail_1( \
1108
6.62k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, sizeof(T)); \
1109
6.62k
    uint64_t Val = \
1110
6.62k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1111
6.62k
    SStream_concat(O, "%s", markup("<imm:")); \
1112
6.62k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1113
6.62k
             Val, 8 * sizeof(T)))); \
1114
6.62k
    SStream_concat0(O, markup(">")); \
1115
6.62k
  }
printLogicalImm_int64_t
Line
Count
Source
1106
2.04k
  { \
1107
2.04k
    AArch64_add_cs_detail_1( \
1108
2.04k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, sizeof(T)); \
1109
2.04k
    uint64_t Val = \
1110
2.04k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1111
2.04k
    SStream_concat(O, "%s", markup("<imm:")); \
1112
2.04k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1113
2.04k
             Val, 8 * sizeof(T)))); \
1114
2.04k
    SStream_concat0(O, markup(">")); \
1115
2.04k
  }
printLogicalImm_int32_t
Line
Count
Source
1106
2.02k
  { \
1107
2.02k
    AArch64_add_cs_detail_1( \
1108
2.02k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, sizeof(T)); \
1109
2.02k
    uint64_t Val = \
1110
2.02k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1111
2.02k
    SStream_concat(O, "%s", markup("<imm:")); \
1112
2.02k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1113
2.02k
             Val, 8 * sizeof(T)))); \
1114
2.02k
    SStream_concat0(O, markup(">")); \
1115
2.02k
  }
printLogicalImm_int8_t
Line
Count
Source
1106
1.78k
  { \
1107
1.78k
    AArch64_add_cs_detail_1( \
1108
1.78k
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, sizeof(T)); \
1109
1.78k
    uint64_t Val = \
1110
1.78k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1111
1.78k
    SStream_concat(O, "%s", markup("<imm:")); \
1112
1.78k
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1113
1.78k
             Val, 8 * sizeof(T)))); \
1114
1.78k
    SStream_concat0(O, markup(">")); \
1115
1.78k
  }
printLogicalImm_int16_t
Line
Count
Source
1106
767
  { \
1107
767
    AArch64_add_cs_detail_1( \
1108
767
      MI, CONCAT(AArch64_OP_GROUP_LogicalImm, T), OpNum, sizeof(T)); \
1109
767
    uint64_t Val = \
1110
767
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1111
767
    SStream_concat(O, "%s", markup("<imm:")); \
1112
767
    printUInt64Bang(O, (AArch64_AM_decodeLogicalImmediate( \
1113
767
             Val, 8 * sizeof(T)))); \
1114
767
    SStream_concat0(O, markup(">")); \
1115
767
  }
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
9.56k
{
1123
9.56k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_Shifter, OpNum);
1124
9.56k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1125
  // LSL #0 should not be printed.
1126
9.56k
  if (AArch64_AM_getShiftType(Val) == AArch64_AM_LSL &&
1127
9.56k
      AArch64_AM_getShiftValue(Val) == 0)
1128
522
    return;
1129
9.03k
  SStream_concat(
1130
9.03k
    O, "%s%s%s%s#%d", ", ",
1131
9.03k
    AArch64_AM_getShiftExtendName(AArch64_AM_getShiftType(Val)),
1132
9.03k
    " ", markup("<imm:"), AArch64_AM_getShiftValue(Val));
1133
9.03k
  SStream_concat0(O, markup(">"));
1134
9.03k
}
1135
1136
void printShiftedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1137
5.50k
{
1138
5.50k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ShiftedRegister, OpNum);
1139
5.50k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1140
5.50k
  printShifter(MI, OpNum + 1, O);
1141
5.50k
}
1142
1143
void printExtendedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1144
950
{
1145
950
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ExtendedRegister, OpNum);
1146
950
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1147
950
  printArithExtend(MI, OpNum + 1, O);
1148
950
}
1149
1150
void printArithExtend(MCInst *MI, unsigned OpNum, SStream *O)
1151
2.06k
{
1152
2.06k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_ArithExtend, OpNum);
1153
2.06k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1154
2.06k
  AArch64_AM_ShiftExtendType ExtType = AArch64_AM_getArithExtendType(Val);
1155
2.06k
  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.06k
  if (ExtType == AArch64_AM_UXTW || ExtType == AArch64_AM_UXTX) {
1161
493
    unsigned Dest = MCOperand_getReg(MCInst_getOperand(MI, (0)));
1162
493
    unsigned Src1 = MCOperand_getReg(MCInst_getOperand(MI, (1)));
1163
493
    if (((Dest == AArch64_SP || Src1 == AArch64_SP) &&
1164
493
         ExtType == AArch64_AM_UXTX) ||
1165
493
        ((Dest == AArch64_WSP || Src1 == AArch64_WSP) &&
1166
459
         ExtType == AArch64_AM_UXTW)) {
1167
96
      if (ShiftVal != 0) {
1168
96
        SStream_concat(O, "%s%s", ", lsl ",
1169
96
                 markup("<imm:"));
1170
96
        printUInt32Bang(O, ShiftVal);
1171
96
        SStream_concat0(O, markup(">"));
1172
96
      }
1173
96
      return;
1174
96
    }
1175
493
  }
1176
1.97k
  SStream_concat(O, "%s", ", ");
1177
1.97k
  SStream_concat0(O, AArch64_AM_getShiftExtendName(ExtType));
1178
1.97k
  if (ShiftVal != 0) {
1179
1.48k
    SStream_concat(O, "%s%s#%d", " ", markup("<imm:"), ShiftVal);
1180
1.48k
    SStream_concat0(O, markup(">"));
1181
1.48k
  }
1182
1.97k
}
1183
1184
static void printMemExtendImpl(bool SignExtend, bool DoShift, unsigned Width,
1185
             char SrcRegKind, SStream *O, bool getUseMarkup)
1186
11.5k
{
1187
  // sxtw, sxtx, uxtw or lsl (== uxtx)
1188
11.5k
  bool IsLSL = !SignExtend && SrcRegKind == 'x';
1189
11.5k
  if (IsLSL)
1190
4.57k
    SStream_concat0(O, "lsl");
1191
6.96k
  else {
1192
6.96k
    SStream_concat(O, "%c%s", (SignExtend ? 's' : 'u'), "xt");
1193
6.96k
    SStream_concat1(O, SrcRegKind);
1194
6.96k
  }
1195
1196
11.5k
  if (DoShift || IsLSL) {
1197
7.64k
    SStream_concat0(O, " ");
1198
7.64k
    if (getUseMarkup)
1199
0
      SStream_concat0(O, "<imm:");
1200
7.64k
    unsigned ShiftAmount = DoShift ? Log2_32(Width / 8) : 0;
1201
7.64k
    SStream_concat(O, "%s%d", "#", ShiftAmount);
1202
7.64k
    if (getUseMarkup)
1203
0
      SStream_concat0(O, ">");
1204
7.64k
  }
1205
11.5k
}
1206
1207
void printMemExtend(MCInst *MI, unsigned OpNum, SStream *O, char SrcRegKind,
1208
        unsigned Width)
1209
3.09k
{
1210
3.09k
  bool SignExtend = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1211
3.09k
  bool DoShift = MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1)));
1212
3.09k
  printMemExtendImpl(SignExtend, DoShift, Width, SrcRegKind, O,
1213
3.09k
         getUseMarkup());
1214
3.09k
}
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
10.8k
  { \
1223
10.8k
    AArch64_add_cs_detail_4( \
1224
10.8k
      MI, \
1225
10.8k
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
10.8k
                SignExtend), \
1227
10.8k
               ExtWidth), \
1228
10.8k
              SrcRegKind), \
1229
10.8k
             Suffix), \
1230
10.8k
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
10.8k
      CHAR(Suffix)); \
1232
10.8k
    printOperand(MI, OpNum, O); \
1233
10.8k
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
6.66k
      SStream_concat1(O, '.'); \
1235
6.66k
      SStream_concat1(O, CHAR(Suffix)); \
1236
6.66k
      SStream_concat1(O, '\0'); \
1237
6.66k
    } else \
1238
10.8k
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
10.8k
             "Unsupported suffix size"); \
1240
10.8k
    bool DoShift = ExtWidth != 8; \
1241
10.8k
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
8.44k
      SStream_concat0(O, ", "); \
1243
8.44k
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
8.44k
             CHAR(SrcRegKind), O, \
1245
8.44k
             getUseMarkup()); \
1246
8.44k
    } \
1247
10.8k
  }
printRegWithShiftExtend_0_8_x_d
Line
Count
Source
1222
922
  { \
1223
922
    AArch64_add_cs_detail_4( \
1224
922
      MI, \
1225
922
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
922
                SignExtend), \
1227
922
               ExtWidth), \
1228
922
              SrcRegKind), \
1229
922
             Suffix), \
1230
922
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
922
      CHAR(Suffix)); \
1232
922
    printOperand(MI, OpNum, O); \
1233
922
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
922
      SStream_concat1(O, '.'); \
1235
922
      SStream_concat1(O, CHAR(Suffix)); \
1236
922
      SStream_concat1(O, '\0'); \
1237
922
    } else \
1238
922
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
922
             "Unsupported suffix size"); \
1240
922
    bool DoShift = ExtWidth != 8; \
1241
922
    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
922
  }
printRegWithShiftExtend_1_8_w_d
Line
Count
Source
1222
656
  { \
1223
656
    AArch64_add_cs_detail_4( \
1224
656
      MI, \
1225
656
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
656
                SignExtend), \
1227
656
               ExtWidth), \
1228
656
              SrcRegKind), \
1229
656
             Suffix), \
1230
656
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
656
      CHAR(Suffix)); \
1232
656
    printOperand(MI, OpNum, O); \
1233
656
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
656
      SStream_concat1(O, '.'); \
1235
656
      SStream_concat1(O, CHAR(Suffix)); \
1236
656
      SStream_concat1(O, '\0'); \
1237
656
    } else \
1238
656
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
656
             "Unsupported suffix size"); \
1240
656
    bool DoShift = ExtWidth != 8; \
1241
656
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
656
      SStream_concat0(O, ", "); \
1243
656
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
656
             CHAR(SrcRegKind), O, \
1245
656
             getUseMarkup()); \
1246
656
    } \
1247
656
  }
printRegWithShiftExtend_0_8_w_d
Line
Count
Source
1222
1.53k
  { \
1223
1.53k
    AArch64_add_cs_detail_4( \
1224
1.53k
      MI, \
1225
1.53k
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
1.53k
                SignExtend), \
1227
1.53k
               ExtWidth), \
1228
1.53k
              SrcRegKind), \
1229
1.53k
             Suffix), \
1230
1.53k
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
1.53k
      CHAR(Suffix)); \
1232
1.53k
    printOperand(MI, OpNum, O); \
1233
1.53k
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
1.53k
      SStream_concat1(O, '.'); \
1235
1.53k
      SStream_concat1(O, CHAR(Suffix)); \
1236
1.53k
      SStream_concat1(O, '\0'); \
1237
1.53k
    } else \
1238
1.53k
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
1.53k
             "Unsupported suffix size"); \
1240
1.53k
    bool DoShift = ExtWidth != 8; \
1241
1.53k
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
1.53k
      SStream_concat0(O, ", "); \
1243
1.53k
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
1.53k
             CHAR(SrcRegKind), O, \
1245
1.53k
             getUseMarkup()); \
1246
1.53k
    } \
1247
1.53k
  }
printRegWithShiftExtend_0_8_x_0
Line
Count
Source
1222
1.47k
  { \
1223
1.47k
    AArch64_add_cs_detail_4( \
1224
1.47k
      MI, \
1225
1.47k
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
1.47k
                SignExtend), \
1227
1.47k
               ExtWidth), \
1228
1.47k
              SrcRegKind), \
1229
1.47k
             Suffix), \
1230
1.47k
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
1.47k
      CHAR(Suffix)); \
1232
1.47k
    printOperand(MI, OpNum, O); \
1233
1.47k
    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
1.47k
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
1.47k
             "Unsupported suffix size"); \
1240
1.47k
    bool DoShift = ExtWidth != 8; \
1241
1.47k
    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
1.47k
  }
printRegWithShiftExtend_1_8_w_s
Line
Count
Source
1222
343
  { \
1223
343
    AArch64_add_cs_detail_4( \
1224
343
      MI, \
1225
343
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
343
                SignExtend), \
1227
343
               ExtWidth), \
1228
343
              SrcRegKind), \
1229
343
             Suffix), \
1230
343
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
343
      CHAR(Suffix)); \
1232
343
    printOperand(MI, OpNum, O); \
1233
343
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
343
      SStream_concat1(O, '.'); \
1235
343
      SStream_concat1(O, CHAR(Suffix)); \
1236
343
      SStream_concat1(O, '\0'); \
1237
343
    } else \
1238
343
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
343
             "Unsupported suffix size"); \
1240
343
    bool DoShift = ExtWidth != 8; \
1241
343
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
343
      SStream_concat0(O, ", "); \
1243
343
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
343
             CHAR(SrcRegKind), O, \
1245
343
             getUseMarkup()); \
1246
343
    } \
1247
343
  }
printRegWithShiftExtend_0_8_w_s
Line
Count
Source
1222
246
  { \
1223
246
    AArch64_add_cs_detail_4( \
1224
246
      MI, \
1225
246
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
246
                SignExtend), \
1227
246
               ExtWidth), \
1228
246
              SrcRegKind), \
1229
246
             Suffix), \
1230
246
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
246
      CHAR(Suffix)); \
1232
246
    printOperand(MI, OpNum, O); \
1233
246
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
246
      SStream_concat1(O, '.'); \
1235
246
      SStream_concat1(O, CHAR(Suffix)); \
1236
246
      SStream_concat1(O, '\0'); \
1237
246
    } else \
1238
246
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
246
             "Unsupported suffix size"); \
1240
246
    bool DoShift = ExtWidth != 8; \
1241
246
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
246
      SStream_concat0(O, ", "); \
1243
246
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
246
             CHAR(SrcRegKind), O, \
1245
246
             getUseMarkup()); \
1246
246
    } \
1247
246
  }
printRegWithShiftExtend_0_64_x_d
Line
Count
Source
1222
108
  { \
1223
108
    AArch64_add_cs_detail_4( \
1224
108
      MI, \
1225
108
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
108
                SignExtend), \
1227
108
               ExtWidth), \
1228
108
              SrcRegKind), \
1229
108
             Suffix), \
1230
108
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
108
      CHAR(Suffix)); \
1232
108
    printOperand(MI, OpNum, O); \
1233
108
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
108
      SStream_concat1(O, '.'); \
1235
108
      SStream_concat1(O, CHAR(Suffix)); \
1236
108
      SStream_concat1(O, '\0'); \
1237
108
    } else \
1238
108
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
108
             "Unsupported suffix size"); \
1240
108
    bool DoShift = ExtWidth != 8; \
1241
108
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
108
      SStream_concat0(O, ", "); \
1243
108
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
108
             CHAR(SrcRegKind), O, \
1245
108
             getUseMarkup()); \
1246
108
    } \
1247
108
  }
printRegWithShiftExtend_1_64_w_d
Line
Count
Source
1222
168
  { \
1223
168
    AArch64_add_cs_detail_4( \
1224
168
      MI, \
1225
168
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
168
                SignExtend), \
1227
168
               ExtWidth), \
1228
168
              SrcRegKind), \
1229
168
             Suffix), \
1230
168
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
168
      CHAR(Suffix)); \
1232
168
    printOperand(MI, OpNum, O); \
1233
168
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
168
      SStream_concat1(O, '.'); \
1235
168
      SStream_concat1(O, CHAR(Suffix)); \
1236
168
      SStream_concat1(O, '\0'); \
1237
168
    } else \
1238
168
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
168
             "Unsupported suffix size"); \
1240
168
    bool DoShift = ExtWidth != 8; \
1241
168
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
168
      SStream_concat0(O, ", "); \
1243
168
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
168
             CHAR(SrcRegKind), O, \
1245
168
             getUseMarkup()); \
1246
168
    } \
1247
168
  }
printRegWithShiftExtend_0_64_w_d
Line
Count
Source
1222
361
  { \
1223
361
    AArch64_add_cs_detail_4( \
1224
361
      MI, \
1225
361
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
361
                SignExtend), \
1227
361
               ExtWidth), \
1228
361
              SrcRegKind), \
1229
361
             Suffix), \
1230
361
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
361
      CHAR(Suffix)); \
1232
361
    printOperand(MI, OpNum, O); \
1233
361
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
361
      SStream_concat1(O, '.'); \
1235
361
      SStream_concat1(O, CHAR(Suffix)); \
1236
361
      SStream_concat1(O, '\0'); \
1237
361
    } else \
1238
361
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
361
             "Unsupported suffix size"); \
1240
361
    bool DoShift = ExtWidth != 8; \
1241
361
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
361
      SStream_concat0(O, ", "); \
1243
361
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
361
             CHAR(SrcRegKind), O, \
1245
361
             getUseMarkup()); \
1246
361
    } \
1247
361
  }
printRegWithShiftExtend_0_64_x_0
Line
Count
Source
1222
807
  { \
1223
807
    AArch64_add_cs_detail_4( \
1224
807
      MI, \
1225
807
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
807
                SignExtend), \
1227
807
               ExtWidth), \
1228
807
              SrcRegKind), \
1229
807
             Suffix), \
1230
807
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
807
      CHAR(Suffix)); \
1232
807
    printOperand(MI, OpNum, O); \
1233
807
    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
807
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
807
             "Unsupported suffix size"); \
1240
807
    bool DoShift = ExtWidth != 8; \
1241
807
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
807
      SStream_concat0(O, ", "); \
1243
807
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
807
             CHAR(SrcRegKind), O, \
1245
807
             getUseMarkup()); \
1246
807
    } \
1247
807
  }
printRegWithShiftExtend_1_64_w_s
Line
Count
Source
1222
253
  { \
1223
253
    AArch64_add_cs_detail_4( \
1224
253
      MI, \
1225
253
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
253
                SignExtend), \
1227
253
               ExtWidth), \
1228
253
              SrcRegKind), \
1229
253
             Suffix), \
1230
253
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
253
      CHAR(Suffix)); \
1232
253
    printOperand(MI, OpNum, O); \
1233
253
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
253
      SStream_concat1(O, '.'); \
1235
253
      SStream_concat1(O, CHAR(Suffix)); \
1236
253
      SStream_concat1(O, '\0'); \
1237
253
    } else \
1238
253
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
253
             "Unsupported suffix size"); \
1240
253
    bool DoShift = ExtWidth != 8; \
1241
253
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
253
      SStream_concat0(O, ", "); \
1243
253
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
253
             CHAR(SrcRegKind), O, \
1245
253
             getUseMarkup()); \
1246
253
    } \
1247
253
  }
printRegWithShiftExtend_0_64_w_s
Line
Count
Source
1222
16
  { \
1223
16
    AArch64_add_cs_detail_4( \
1224
16
      MI, \
1225
16
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
16
                SignExtend), \
1227
16
               ExtWidth), \
1228
16
              SrcRegKind), \
1229
16
             Suffix), \
1230
16
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
16
      CHAR(Suffix)); \
1232
16
    printOperand(MI, OpNum, O); \
1233
16
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
16
      SStream_concat1(O, '.'); \
1235
16
      SStream_concat1(O, CHAR(Suffix)); \
1236
16
      SStream_concat1(O, '\0'); \
1237
16
    } else \
1238
16
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
16
             "Unsupported suffix size"); \
1240
16
    bool DoShift = ExtWidth != 8; \
1241
16
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
16
      SStream_concat0(O, ", "); \
1243
16
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
16
             CHAR(SrcRegKind), O, \
1245
16
             getUseMarkup()); \
1246
16
    } \
1247
16
  }
printRegWithShiftExtend_0_16_x_d
Line
Count
Source
1222
138
  { \
1223
138
    AArch64_add_cs_detail_4( \
1224
138
      MI, \
1225
138
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
138
                SignExtend), \
1227
138
               ExtWidth), \
1228
138
              SrcRegKind), \
1229
138
             Suffix), \
1230
138
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
138
      CHAR(Suffix)); \
1232
138
    printOperand(MI, OpNum, O); \
1233
138
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
138
      SStream_concat1(O, '.'); \
1235
138
      SStream_concat1(O, CHAR(Suffix)); \
1236
138
      SStream_concat1(O, '\0'); \
1237
138
    } else \
1238
138
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
138
             "Unsupported suffix size"); \
1240
138
    bool DoShift = ExtWidth != 8; \
1241
138
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
138
      SStream_concat0(O, ", "); \
1243
138
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
138
             CHAR(SrcRegKind), O, \
1245
138
             getUseMarkup()); \
1246
138
    } \
1247
138
  }
printRegWithShiftExtend_1_16_w_d
Line
Count
Source
1222
153
  { \
1223
153
    AArch64_add_cs_detail_4( \
1224
153
      MI, \
1225
153
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
153
                SignExtend), \
1227
153
               ExtWidth), \
1228
153
              SrcRegKind), \
1229
153
             Suffix), \
1230
153
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
153
      CHAR(Suffix)); \
1232
153
    printOperand(MI, OpNum, O); \
1233
153
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
153
      SStream_concat1(O, '.'); \
1235
153
      SStream_concat1(O, CHAR(Suffix)); \
1236
153
      SStream_concat1(O, '\0'); \
1237
153
    } else \
1238
153
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
153
             "Unsupported suffix size"); \
1240
153
    bool DoShift = ExtWidth != 8; \
1241
153
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
153
      SStream_concat0(O, ", "); \
1243
153
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
153
             CHAR(SrcRegKind), O, \
1245
153
             getUseMarkup()); \
1246
153
    } \
1247
153
  }
printRegWithShiftExtend_0_16_w_d
Line
Count
Source
1222
192
  { \
1223
192
    AArch64_add_cs_detail_4( \
1224
192
      MI, \
1225
192
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
192
                SignExtend), \
1227
192
               ExtWidth), \
1228
192
              SrcRegKind), \
1229
192
             Suffix), \
1230
192
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
192
      CHAR(Suffix)); \
1232
192
    printOperand(MI, OpNum, O); \
1233
192
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
192
      SStream_concat1(O, '.'); \
1235
192
      SStream_concat1(O, CHAR(Suffix)); \
1236
192
      SStream_concat1(O, '\0'); \
1237
192
    } else \
1238
192
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
192
             "Unsupported suffix size"); \
1240
192
    bool DoShift = ExtWidth != 8; \
1241
192
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
192
      SStream_concat0(O, ", "); \
1243
192
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
192
             CHAR(SrcRegKind), O, \
1245
192
             getUseMarkup()); \
1246
192
    } \
1247
192
  }
printRegWithShiftExtend_0_16_x_0
Line
Count
Source
1222
762
  { \
1223
762
    AArch64_add_cs_detail_4( \
1224
762
      MI, \
1225
762
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
762
                SignExtend), \
1227
762
               ExtWidth), \
1228
762
              SrcRegKind), \
1229
762
             Suffix), \
1230
762
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
762
      CHAR(Suffix)); \
1232
762
    printOperand(MI, OpNum, O); \
1233
762
    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
762
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
762
             "Unsupported suffix size"); \
1240
762
    bool DoShift = ExtWidth != 8; \
1241
762
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
762
      SStream_concat0(O, ", "); \
1243
762
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
762
             CHAR(SrcRegKind), O, \
1245
762
             getUseMarkup()); \
1246
762
    } \
1247
762
  }
printRegWithShiftExtend_1_16_w_s
Line
Count
Source
1222
107
  { \
1223
107
    AArch64_add_cs_detail_4( \
1224
107
      MI, \
1225
107
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
107
                SignExtend), \
1227
107
               ExtWidth), \
1228
107
              SrcRegKind), \
1229
107
             Suffix), \
1230
107
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
107
      CHAR(Suffix)); \
1232
107
    printOperand(MI, OpNum, O); \
1233
107
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
107
      SStream_concat1(O, '.'); \
1235
107
      SStream_concat1(O, CHAR(Suffix)); \
1236
107
      SStream_concat1(O, '\0'); \
1237
107
    } else \
1238
107
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
107
             "Unsupported suffix size"); \
1240
107
    bool DoShift = ExtWidth != 8; \
1241
107
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
107
      SStream_concat0(O, ", "); \
1243
107
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
107
             CHAR(SrcRegKind), O, \
1245
107
             getUseMarkup()); \
1246
107
    } \
1247
107
  }
printRegWithShiftExtend_0_16_w_s
Line
Count
Source
1222
134
  { \
1223
134
    AArch64_add_cs_detail_4( \
1224
134
      MI, \
1225
134
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
134
                SignExtend), \
1227
134
               ExtWidth), \
1228
134
              SrcRegKind), \
1229
134
             Suffix), \
1230
134
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
134
      CHAR(Suffix)); \
1232
134
    printOperand(MI, OpNum, O); \
1233
134
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
134
      SStream_concat1(O, '.'); \
1235
134
      SStream_concat1(O, CHAR(Suffix)); \
1236
134
      SStream_concat1(O, '\0'); \
1237
134
    } else \
1238
134
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
134
             "Unsupported suffix size"); \
1240
134
    bool DoShift = ExtWidth != 8; \
1241
134
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
134
      SStream_concat0(O, ", "); \
1243
134
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
134
             CHAR(SrcRegKind), O, \
1245
134
             getUseMarkup()); \
1246
134
    } \
1247
134
  }
printRegWithShiftExtend_0_32_x_d
Line
Count
Source
1222
306
  { \
1223
306
    AArch64_add_cs_detail_4( \
1224
306
      MI, \
1225
306
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
306
                SignExtend), \
1227
306
               ExtWidth), \
1228
306
              SrcRegKind), \
1229
306
             Suffix), \
1230
306
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
306
      CHAR(Suffix)); \
1232
306
    printOperand(MI, OpNum, O); \
1233
306
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
306
      SStream_concat1(O, '.'); \
1235
306
      SStream_concat1(O, CHAR(Suffix)); \
1236
306
      SStream_concat1(O, '\0'); \
1237
306
    } else \
1238
306
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
306
             "Unsupported suffix size"); \
1240
306
    bool DoShift = ExtWidth != 8; \
1241
306
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
306
      SStream_concat0(O, ", "); \
1243
306
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
306
             CHAR(SrcRegKind), O, \
1245
306
             getUseMarkup()); \
1246
306
    } \
1247
306
  }
printRegWithShiftExtend_1_32_w_d
Line
Count
Source
1222
277
  { \
1223
277
    AArch64_add_cs_detail_4( \
1224
277
      MI, \
1225
277
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
277
                SignExtend), \
1227
277
               ExtWidth), \
1228
277
              SrcRegKind), \
1229
277
             Suffix), \
1230
277
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
277
      CHAR(Suffix)); \
1232
277
    printOperand(MI, OpNum, O); \
1233
277
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
277
      SStream_concat1(O, '.'); \
1235
277
      SStream_concat1(O, CHAR(Suffix)); \
1236
277
      SStream_concat1(O, '\0'); \
1237
277
    } else \
1238
277
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
277
             "Unsupported suffix size"); \
1240
277
    bool DoShift = ExtWidth != 8; \
1241
277
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
277
      SStream_concat0(O, ", "); \
1243
277
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
277
             CHAR(SrcRegKind), O, \
1245
277
             getUseMarkup()); \
1246
277
    } \
1247
277
  }
printRegWithShiftExtend_0_32_w_d
Line
Count
Source
1222
376
  { \
1223
376
    AArch64_add_cs_detail_4( \
1224
376
      MI, \
1225
376
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
376
                SignExtend), \
1227
376
               ExtWidth), \
1228
376
              SrcRegKind), \
1229
376
             Suffix), \
1230
376
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
376
      CHAR(Suffix)); \
1232
376
    printOperand(MI, OpNum, O); \
1233
376
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
376
      SStream_concat1(O, '.'); \
1235
376
      SStream_concat1(O, CHAR(Suffix)); \
1236
376
      SStream_concat1(O, '\0'); \
1237
376
    } else \
1238
376
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
376
             "Unsupported suffix size"); \
1240
376
    bool DoShift = ExtWidth != 8; \
1241
376
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
376
      SStream_concat0(O, ", "); \
1243
376
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
376
             CHAR(SrcRegKind), O, \
1245
376
             getUseMarkup()); \
1246
376
    } \
1247
376
  }
printRegWithShiftExtend_0_32_x_0
Line
Count
Source
1222
494
  { \
1223
494
    AArch64_add_cs_detail_4( \
1224
494
      MI, \
1225
494
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
494
                SignExtend), \
1227
494
               ExtWidth), \
1228
494
              SrcRegKind), \
1229
494
             Suffix), \
1230
494
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
494
      CHAR(Suffix)); \
1232
494
    printOperand(MI, OpNum, O); \
1233
494
    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
494
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
494
             "Unsupported suffix size"); \
1240
494
    bool DoShift = ExtWidth != 8; \
1241
494
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
494
      SStream_concat0(O, ", "); \
1243
494
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
494
             CHAR(SrcRegKind), O, \
1245
494
             getUseMarkup()); \
1246
494
    } \
1247
494
  }
printRegWithShiftExtend_1_32_w_s
Line
Count
Source
1222
107
  { \
1223
107
    AArch64_add_cs_detail_4( \
1224
107
      MI, \
1225
107
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
107
                SignExtend), \
1227
107
               ExtWidth), \
1228
107
              SrcRegKind), \
1229
107
             Suffix), \
1230
107
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
107
      CHAR(Suffix)); \
1232
107
    printOperand(MI, OpNum, O); \
1233
107
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
107
      SStream_concat1(O, '.'); \
1235
107
      SStream_concat1(O, CHAR(Suffix)); \
1236
107
      SStream_concat1(O, '\0'); \
1237
107
    } else \
1238
107
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
107
             "Unsupported suffix size"); \
1240
107
    bool DoShift = ExtWidth != 8; \
1241
107
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
107
      SStream_concat0(O, ", "); \
1243
107
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
107
             CHAR(SrcRegKind), O, \
1245
107
             getUseMarkup()); \
1246
107
    } \
1247
107
  }
printRegWithShiftExtend_0_32_w_s
Line
Count
Source
1222
151
  { \
1223
151
    AArch64_add_cs_detail_4( \
1224
151
      MI, \
1225
151
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
151
                SignExtend), \
1227
151
               ExtWidth), \
1228
151
              SrcRegKind), \
1229
151
             Suffix), \
1230
151
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
151
      CHAR(Suffix)); \
1232
151
    printOperand(MI, OpNum, O); \
1233
151
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
151
      SStream_concat1(O, '.'); \
1235
151
      SStream_concat1(O, CHAR(Suffix)); \
1236
151
      SStream_concat1(O, '\0'); \
1237
151
    } else \
1238
151
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
151
             "Unsupported suffix size"); \
1240
151
    bool DoShift = ExtWidth != 8; \
1241
151
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
151
      SStream_concat0(O, ", "); \
1243
151
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
151
             CHAR(SrcRegKind), O, \
1245
151
             getUseMarkup()); \
1246
151
    } \
1247
151
  }
printRegWithShiftExtend_0_8_x_s
Line
Count
Source
1222
11
  { \
1223
11
    AArch64_add_cs_detail_4( \
1224
11
      MI, \
1225
11
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
11
                SignExtend), \
1227
11
               ExtWidth), \
1228
11
              SrcRegKind), \
1229
11
             Suffix), \
1230
11
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
11
      CHAR(Suffix)); \
1232
11
    printOperand(MI, OpNum, O); \
1233
11
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
11
      SStream_concat1(O, '.'); \
1235
11
      SStream_concat1(O, CHAR(Suffix)); \
1236
11
      SStream_concat1(O, '\0'); \
1237
11
    } else \
1238
11
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
11
             "Unsupported suffix size"); \
1240
11
    bool DoShift = ExtWidth != 8; \
1241
11
    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
11
  }
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
72
  { \
1223
72
    AArch64_add_cs_detail_4( \
1224
72
      MI, \
1225
72
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
72
                SignExtend), \
1227
72
               ExtWidth), \
1228
72
              SrcRegKind), \
1229
72
             Suffix), \
1230
72
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
72
      CHAR(Suffix)); \
1232
72
    printOperand(MI, OpNum, O); \
1233
72
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
72
      SStream_concat1(O, '.'); \
1235
72
      SStream_concat1(O, CHAR(Suffix)); \
1236
72
      SStream_concat1(O, '\0'); \
1237
72
    } else \
1238
72
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
72
             "Unsupported suffix size"); \
1240
72
    bool DoShift = ExtWidth != 8; \
1241
72
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
72
      SStream_concat0(O, ", "); \
1243
72
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
72
             CHAR(SrcRegKind), O, \
1245
72
             getUseMarkup()); \
1246
72
    } \
1247
72
  }
printRegWithShiftExtend_0_64_x_s
Line
Count
Source
1222
11
  { \
1223
11
    AArch64_add_cs_detail_4( \
1224
11
      MI, \
1225
11
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
11
                SignExtend), \
1227
11
               ExtWidth), \
1228
11
              SrcRegKind), \
1229
11
             Suffix), \
1230
11
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
11
      CHAR(Suffix)); \
1232
11
    printOperand(MI, OpNum, O); \
1233
11
    if (CHAR(Suffix) == 's' || CHAR(Suffix) == 'd') { \
1234
11
      SStream_concat1(O, '.'); \
1235
11
      SStream_concat1(O, CHAR(Suffix)); \
1236
11
      SStream_concat1(O, '\0'); \
1237
11
    } else \
1238
11
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
11
             "Unsupported suffix size"); \
1240
11
    bool DoShift = ExtWidth != 8; \
1241
11
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
11
      SStream_concat0(O, ", "); \
1243
11
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
11
             CHAR(SrcRegKind), O, \
1245
11
             getUseMarkup()); \
1246
11
    } \
1247
11
  }
printRegWithShiftExtend_0_128_x_0
Line
Count
Source
1222
650
  { \
1223
650
    AArch64_add_cs_detail_4( \
1224
650
      MI, \
1225
650
      CONCAT(CONCAT(CONCAT(CONCAT(AArch64_OP_GROUP_RegWithShiftExtend, \
1226
650
                SignExtend), \
1227
650
               ExtWidth), \
1228
650
              SrcRegKind), \
1229
650
             Suffix), \
1230
650
      OpNum, SignExtend, ExtWidth, CHAR(SrcRegKind), \
1231
650
      CHAR(Suffix)); \
1232
650
    printOperand(MI, OpNum, O); \
1233
650
    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
650
      CS_ASSERT_RET((CHAR(Suffix) == '0') && \
1239
650
             "Unsupported suffix size"); \
1240
650
    bool DoShift = ExtWidth != 8; \
1241
650
    if (SignExtend || DoShift || CHAR(SrcRegKind) == 'w') { \
1242
650
      SStream_concat0(O, ", "); \
1243
650
      printMemExtendImpl(SignExtend, DoShift, ExtWidth, \
1244
650
             CHAR(SrcRegKind), O, \
1245
650
             getUseMarkup()); \
1246
650
    } \
1247
650
  }
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
5.23k
  { \
1282
5.23k
    AArch64_add_cs_detail_1( \
1283
5.23k
      MI, \
1284
5.23k
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1285
5.23k
      OpNum, EltSize); \
1286
5.23k
    unsigned Reg = \
1287
5.23k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1288
5.23k
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1289
5.23k
      CS_ASSERT_RET(0 && \
1290
5.23k
             "Unsupported predicate-as-counter register"); \
1291
5.23k
    SStream_concat(O, "%s", "pn"); \
1292
5.23k
    printUInt32(O, (Reg - AArch64_PN0)); \
1293
5.23k
    switch (EltSize) { \
1294
4.80k
    case 0: \
1295
4.80k
      break; \
1296
115
    case 8: \
1297
115
      SStream_concat0(O, ".b"); \
1298
115
      break; \
1299
102
    case 16: \
1300
102
      SStream_concat0(O, ".h"); \
1301
102
      break; \
1302
54
    case 32: \
1303
54
      SStream_concat0(O, ".s"); \
1304
54
      break; \
1305
161
    case 64: \
1306
161
      SStream_concat0(O, ".d"); \
1307
161
      break; \
1308
0
    default: \
1309
0
      CS_ASSERT_RET(0 && "Unsupported element size"); \
1310
5.23k
    } \
1311
5.23k
  }
printPredicateAsCounter_8
Line
Count
Source
1281
115
  { \
1282
115
    AArch64_add_cs_detail_1( \
1283
115
      MI, \
1284
115
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1285
115
      OpNum, EltSize); \
1286
115
    unsigned Reg = \
1287
115
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1288
115
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1289
115
      CS_ASSERT_RET(0 && \
1290
115
             "Unsupported predicate-as-counter register"); \
1291
115
    SStream_concat(O, "%s", "pn"); \
1292
115
    printUInt32(O, (Reg - AArch64_PN0)); \
1293
115
    switch (EltSize) { \
1294
0
    case 0: \
1295
0
      break; \
1296
115
    case 8: \
1297
115
      SStream_concat0(O, ".b"); \
1298
115
      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
115
    } \
1311
115
  }
printPredicateAsCounter_64
Line
Count
Source
1281
161
  { \
1282
161
    AArch64_add_cs_detail_1( \
1283
161
      MI, \
1284
161
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1285
161
      OpNum, EltSize); \
1286
161
    unsigned Reg = \
1287
161
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1288
161
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1289
161
      CS_ASSERT_RET(0 && \
1290
161
             "Unsupported predicate-as-counter register"); \
1291
161
    SStream_concat(O, "%s", "pn"); \
1292
161
    printUInt32(O, (Reg - AArch64_PN0)); \
1293
161
    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
161
    case 64: \
1306
161
      SStream_concat0(O, ".d"); \
1307
161
      break; \
1308
0
    default: \
1309
0
      CS_ASSERT_RET(0 && "Unsupported element size"); \
1310
161
    } \
1311
161
  }
printPredicateAsCounter_16
Line
Count
Source
1281
102
  { \
1282
102
    AArch64_add_cs_detail_1( \
1283
102
      MI, \
1284
102
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1285
102
      OpNum, EltSize); \
1286
102
    unsigned Reg = \
1287
102
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1288
102
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1289
102
      CS_ASSERT_RET(0 && \
1290
102
             "Unsupported predicate-as-counter register"); \
1291
102
    SStream_concat(O, "%s", "pn"); \
1292
102
    printUInt32(O, (Reg - AArch64_PN0)); \
1293
102
    switch (EltSize) { \
1294
0
    case 0: \
1295
0
      break; \
1296
0
    case 8: \
1297
0
      SStream_concat0(O, ".b"); \
1298
0
      break; \
1299
102
    case 16: \
1300
102
      SStream_concat0(O, ".h"); \
1301
102
      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
102
    } \
1311
102
  }
printPredicateAsCounter_32
Line
Count
Source
1281
54
  { \
1282
54
    AArch64_add_cs_detail_1( \
1283
54
      MI, \
1284
54
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1285
54
      OpNum, EltSize); \
1286
54
    unsigned Reg = \
1287
54
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1288
54
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1289
54
      CS_ASSERT_RET(0 && \
1290
54
             "Unsupported predicate-as-counter register"); \
1291
54
    SStream_concat(O, "%s", "pn"); \
1292
54
    printUInt32(O, (Reg - AArch64_PN0)); \
1293
54
    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
54
    case 32: \
1303
54
      SStream_concat0(O, ".s"); \
1304
54
      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
54
    } \
1311
54
  }
printPredicateAsCounter_0
Line
Count
Source
1281
4.80k
  { \
1282
4.80k
    AArch64_add_cs_detail_1( \
1283
4.80k
      MI, \
1284
4.80k
      CONCAT(AArch64_OP_GROUP_PredicateAsCounter, EltSize), \
1285
4.80k
      OpNum, EltSize); \
1286
4.80k
    unsigned Reg = \
1287
4.80k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1288
4.80k
    if (Reg < AArch64_PN0 || Reg > AArch64_PN15) \
1289
4.80k
      CS_ASSERT_RET(0 && \
1290
4.80k
             "Unsupported predicate-as-counter register"); \
1291
4.80k
    SStream_concat(O, "%s", "pn"); \
1292
4.80k
    printUInt32(O, (Reg - AArch64_PN0)); \
1293
4.80k
    switch (EltSize) { \
1294
4.80k
    case 0: \
1295
4.80k
      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
4.80k
    } \
1311
4.80k
  }
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
1.59k
{
1320
1.59k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_CondCode, OpNum);
1321
1.59k
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(
1322
1.59k
    MCInst_getOperand(MI, (OpNum)));
1323
1.59k
  SStream_concat0(O, AArch64CC_getCondCodeName(CC));
1324
1.59k
}
1325
1326
void printInverseCondCode(MCInst *MI, unsigned OpNum, SStream *O)
1327
56
{
1328
56
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_InverseCondCode, OpNum);
1329
56
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(
1330
56
    MCInst_getOperand(MI, (OpNum)));
1331
56
  SStream_concat0(O, AArch64CC_getCondCodeName(
1332
56
           AArch64CC_getInvertedCondCode(CC)));
1333
56
}
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
19.1k
  { \
1348
19.1k
    AArch64_add_cs_detail_1( \
1349
19.1k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1350
19.1k
      Scale); \
1351
19.1k
    SStream_concat(O, "%s", markup("<imm:")); \
1352
19.1k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1353
19.1k
            MCInst_getOperand(MI, (OpNum)))); \
1354
19.1k
    SStream_concat0(O, markup(">")); \
1355
19.1k
  }
printImmScale_8
Line
Count
Source
1347
5.52k
  { \
1348
5.52k
    AArch64_add_cs_detail_1( \
1349
5.52k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1350
5.52k
      Scale); \
1351
5.52k
    SStream_concat(O, "%s", markup("<imm:")); \
1352
5.52k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1353
5.52k
            MCInst_getOperand(MI, (OpNum)))); \
1354
5.52k
    SStream_concat0(O, markup(">")); \
1355
5.52k
  }
printImmScale_2
Line
Count
Source
1347
1.95k
  { \
1348
1.95k
    AArch64_add_cs_detail_1( \
1349
1.95k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1350
1.95k
      Scale); \
1351
1.95k
    SStream_concat(O, "%s", markup("<imm:")); \
1352
1.95k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1353
1.95k
            MCInst_getOperand(MI, (OpNum)))); \
1354
1.95k
    SStream_concat0(O, markup(">")); \
1355
1.95k
  }
printImmScale_4
Line
Count
Source
1347
8.05k
  { \
1348
8.05k
    AArch64_add_cs_detail_1( \
1349
8.05k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1350
8.05k
      Scale); \
1351
8.05k
    SStream_concat(O, "%s", markup("<imm:")); \
1352
8.05k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1353
8.05k
            MCInst_getOperand(MI, (OpNum)))); \
1354
8.05k
    SStream_concat0(O, markup(">")); \
1355
8.05k
  }
printImmScale_16
Line
Count
Source
1347
3.49k
  { \
1348
3.49k
    AArch64_add_cs_detail_1( \
1349
3.49k
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1350
3.49k
      Scale); \
1351
3.49k
    SStream_concat(O, "%s", markup("<imm:")); \
1352
3.49k
    printInt32Bang(O, Scale *MCOperand_getImm( \
1353
3.49k
            MCInst_getOperand(MI, (OpNum)))); \
1354
3.49k
    SStream_concat0(O, markup(">")); \
1355
3.49k
  }
printImmScale_32
Line
Count
Source
1347
40
  { \
1348
40
    AArch64_add_cs_detail_1( \
1349
40
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1350
40
      Scale); \
1351
40
    SStream_concat(O, "%s", markup("<imm:")); \
1352
40
    printInt32Bang(O, Scale *MCOperand_getImm( \
1353
40
            MCInst_getOperand(MI, (OpNum)))); \
1354
40
    SStream_concat0(O, markup(">")); \
1355
40
  }
printImmScale_3
Line
Count
Source
1347
85
  { \
1348
85
    AArch64_add_cs_detail_1( \
1349
85
      MI, CONCAT(AArch64_OP_GROUP_ImmScale, Scale), OpNum, \
1350
85
      Scale); \
1351
85
    SStream_concat(O, "%s", markup("<imm:")); \
1352
85
    printInt32Bang(O, Scale *MCOperand_getImm( \
1353
85
            MCInst_getOperand(MI, (OpNum)))); \
1354
85
    SStream_concat0(O, markup(">")); \
1355
85
  }
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
5.25k
  { \
1367
5.25k
    AArch64_add_cs_detail_2( \
1368
5.25k
      MI, \
1369
5.25k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1370
5.25k
             Offset), \
1371
5.25k
      OpNum, Scale, Offset); \
1372
5.25k
    unsigned FirstImm = \
1373
5.25k
      Scale * \
1374
5.25k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1375
5.25k
    printUInt32(O, (FirstImm)); \
1376
5.25k
    SStream_concat(O, "%s", ":"); \
1377
5.25k
    printUInt32(O, (FirstImm + Offset)); \
1378
5.25k
    SStream_concat1(O, '\0'); \
1379
5.25k
  }
printImmRangeScale_2_1
Line
Count
Source
1366
2.74k
  { \
1367
2.74k
    AArch64_add_cs_detail_2( \
1368
2.74k
      MI, \
1369
2.74k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1370
2.74k
             Offset), \
1371
2.74k
      OpNum, Scale, Offset); \
1372
2.74k
    unsigned FirstImm = \
1373
2.74k
      Scale * \
1374
2.74k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1375
2.74k
    printUInt32(O, (FirstImm)); \
1376
2.74k
    SStream_concat(O, "%s", ":"); \
1377
2.74k
    printUInt32(O, (FirstImm + Offset)); \
1378
2.74k
    SStream_concat1(O, '\0'); \
1379
2.74k
  }
printImmRangeScale_4_3
Line
Count
Source
1366
2.51k
  { \
1367
2.51k
    AArch64_add_cs_detail_2( \
1368
2.51k
      MI, \
1369
2.51k
      CONCAT(CONCAT(AArch64_OP_GROUP_ImmRangeScale, Scale), \
1370
2.51k
             Offset), \
1371
2.51k
      OpNum, Scale, Offset); \
1372
2.51k
    unsigned FirstImm = \
1373
2.51k
      Scale * \
1374
2.51k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1375
2.51k
    printUInt32(O, (FirstImm)); \
1376
2.51k
    SStream_concat(O, "%s", ":"); \
1377
2.51k
    printUInt32(O, (FirstImm + Offset)); \
1378
2.51k
    SStream_concat1(O, '\0'); \
1379
2.51k
  }
1380
DEFINE_printImmRangeScale(2, 1);
1381
DEFINE_printImmRangeScale(4, 3);
1382
1383
void printUImm12Offset(MCInst *MI, unsigned OpNum, unsigned Scale, SStream *O)
1384
4.92k
{
1385
4.92k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1386
4.92k
  if (MCOperand_isImm(MO)) {
1387
4.92k
    SStream_concat(O, "%s", markup("<imm:"));
1388
4.92k
    printUInt32Bang(O, (MCOperand_getImm(MO) * Scale));
1389
4.92k
    SStream_concat0(O, markup(">"));
1390
4.92k
  } else {
1391
0
    printUInt64Bang(O, MCOperand_getImm(MO));
1392
0
  }
1393
4.92k
}
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
319
{
1413
319
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_RPRFMOperand, OpNum);
1414
319
  unsigned prfop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1415
319
  const AArch64PRFM_PRFM *PRFM =
1416
319
    AArch64RPRFM_lookupRPRFMByEncoding(prfop);
1417
319
  if (PRFM) {
1418
184
    SStream_concat0(O, PRFM->Name);
1419
184
    return;
1420
184
  }
1421
1422
135
  printUInt32Bang(O, (prfop));
1423
135
  SStream_concat1(O, '\0');
1424
135
}
1425
1426
#define DEFINE_printPrefetchOp(IsSVEPrefetch) \
1427
  void CONCAT(printPrefetchOp, \
1428
        IsSVEPrefetch)(MCInst * MI, unsigned OpNum, SStream *O) \
1429
4.15k
  { \
1430
4.15k
    AArch64_add_cs_detail_1(MI, \
1431
4.15k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1432
4.15k
                 IsSVEPrefetch), \
1433
4.15k
          OpNum, IsSVEPrefetch); \
1434
4.15k
    unsigned prfop = \
1435
4.15k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1436
4.15k
    if (IsSVEPrefetch) { \
1437
2.64k
      const AArch64SVEPRFM_SVEPRFM *PRFM = \
1438
2.64k
        AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \
1439
2.64k
      if (PRFM) { \
1440
2.16k
        SStream_concat0(O, PRFM->Name); \
1441
2.16k
        return; \
1442
2.16k
      } \
1443
2.64k
    } else { \
1444
1.51k
      const AArch64PRFM_PRFM *PRFM = \
1445
1.51k
        AArch64PRFM_lookupPRFMByEncoding(prfop); \
1446
1.51k
      if (PRFM && \
1447
1.51k
          AArch64_testFeatureList(MI->csh->mode, \
1448
930
                PRFM->FeaturesRequired)) { \
1449
930
        SStream_concat0(O, PRFM->Name); \
1450
930
        return; \
1451
930
      } \
1452
1.51k
    } \
1453
4.15k
\
1454
4.15k
    SStream_concat(O, "%s", markup("<imm:")); \
1455
1.06k
    printUInt32Bang(O, (prfop)); \
1456
1.06k
    SStream_concat0(O, markup(">")); \
1457
1.06k
  }
printPrefetchOp_0
Line
Count
Source
1429
1.51k
  { \
1430
1.51k
    AArch64_add_cs_detail_1(MI, \
1431
1.51k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1432
1.51k
                 IsSVEPrefetch), \
1433
1.51k
          OpNum, IsSVEPrefetch); \
1434
1.51k
    unsigned prfop = \
1435
1.51k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1436
1.51k
    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.51k
    } else { \
1444
1.51k
      const AArch64PRFM_PRFM *PRFM = \
1445
1.51k
        AArch64PRFM_lookupPRFMByEncoding(prfop); \
1446
1.51k
      if (PRFM && \
1447
1.51k
          AArch64_testFeatureList(MI->csh->mode, \
1448
930
                PRFM->FeaturesRequired)) { \
1449
930
        SStream_concat0(O, PRFM->Name); \
1450
930
        return; \
1451
930
      } \
1452
1.51k
    } \
1453
1.51k
\
1454
1.51k
    SStream_concat(O, "%s", markup("<imm:")); \
1455
582
    printUInt32Bang(O, (prfop)); \
1456
582
    SStream_concat0(O, markup(">")); \
1457
582
  }
printPrefetchOp_1
Line
Count
Source
1429
2.64k
  { \
1430
2.64k
    AArch64_add_cs_detail_1(MI, \
1431
2.64k
          CONCAT(AArch64_OP_GROUP_PrefetchOp, \
1432
2.64k
                 IsSVEPrefetch), \
1433
2.64k
          OpNum, IsSVEPrefetch); \
1434
2.64k
    unsigned prfop = \
1435
2.64k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
1436
2.64k
    if (IsSVEPrefetch) { \
1437
2.64k
      const AArch64SVEPRFM_SVEPRFM *PRFM = \
1438
2.64k
        AArch64SVEPRFM_lookupSVEPRFMByEncoding(prfop); \
1439
2.64k
      if (PRFM) { \
1440
2.16k
        SStream_concat0(O, PRFM->Name); \
1441
2.16k
        return; \
1442
2.16k
      } \
1443
2.64k
    } 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
2.64k
\
1454
2.64k
    SStream_concat(O, "%s", markup("<imm:")); \
1455
483
    printUInt32Bang(O, (prfop)); \
1456
483
    SStream_concat0(O, markup(">")); \
1457
483
  }
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
369
{
1479
369
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BTIHintOp, OpNum);
1480
369
  unsigned btihintop = MCOperand_getImm(MCInst_getOperand(MI, (OpNum))) ^
1481
369
           32;
1482
369
  const AArch64BTIHint_BTI *BTI =
1483
369
    AArch64BTIHint_lookupBTIByEncoding(btihintop);
1484
369
  if (BTI)
1485
369
    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
369
}
1492
1493
static void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1494
663
{
1495
663
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_FPImmOperand, OpNum);
1496
663
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1497
663
  float FPImm = MCOperand_isDFPImm(MO) ?
1498
0
            BitsToDouble(MCOperand_getImm(MO)) :
1499
663
            AArch64_AM_getFPImmFloat(MCOperand_getImm(MO));
1500
1501
  // 8 decimal places are enough to perfectly represent permitted floats.
1502
663
  SStream_concat(O, "%s", markup("<imm:"));
1503
663
  SStream_concat(O, "#%.8f", FPImm);
1504
663
  SStream_concat0(O, markup(">"));
1505
663
}
1506
1507
static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride /* = 1 */)
1508
98.9k
{
1509
254k
  while (Stride--) {
1510
156k
    switch (Reg) {
1511
0
    default:
1512
0
      CS_ASSERT_RET_VAL(0 && "Vector register expected!", 0);
1513
4.59k
    case AArch64_Q0:
1514
4.59k
      Reg = AArch64_Q1;
1515
4.59k
      break;
1516
4.30k
    case AArch64_Q1:
1517
4.30k
      Reg = AArch64_Q2;
1518
4.30k
      break;
1519
1.47k
    case AArch64_Q2:
1520
1.47k
      Reg = AArch64_Q3;
1521
1.47k
      break;
1522
906
    case AArch64_Q3:
1523
906
      Reg = AArch64_Q4;
1524
906
      break;
1525
655
    case AArch64_Q4:
1526
655
      Reg = AArch64_Q5;
1527
655
      break;
1528
1.06k
    case AArch64_Q5:
1529
1.06k
      Reg = AArch64_Q6;
1530
1.06k
      break;
1531
1.15k
    case AArch64_Q6:
1532
1.15k
      Reg = AArch64_Q7;
1533
1.15k
      break;
1534
1.16k
    case AArch64_Q7:
1535
1.16k
      Reg = AArch64_Q8;
1536
1.16k
      break;
1537
1.45k
    case AArch64_Q8:
1538
1.45k
      Reg = AArch64_Q9;
1539
1.45k
      break;
1540
1.48k
    case AArch64_Q9:
1541
1.48k
      Reg = AArch64_Q10;
1542
1.48k
      break;
1543
1.00k
    case AArch64_Q10:
1544
1.00k
      Reg = AArch64_Q11;
1545
1.00k
      break;
1546
893
    case AArch64_Q11:
1547
893
      Reg = AArch64_Q12;
1548
893
      break;
1549
771
    case AArch64_Q12:
1550
771
      Reg = AArch64_Q13;
1551
771
      break;
1552
809
    case AArch64_Q13:
1553
809
      Reg = AArch64_Q14;
1554
809
      break;
1555
289
    case AArch64_Q14:
1556
289
      Reg = AArch64_Q15;
1557
289
      break;
1558
371
    case AArch64_Q15:
1559
371
      Reg = AArch64_Q16;
1560
371
      break;
1561
842
    case AArch64_Q16:
1562
842
      Reg = AArch64_Q17;
1563
842
      break;
1564
1.06k
    case AArch64_Q17:
1565
1.06k
      Reg = AArch64_Q18;
1566
1.06k
      break;
1567
1.46k
    case AArch64_Q18:
1568
1.46k
      Reg = AArch64_Q19;
1569
1.46k
      break;
1570
1.63k
    case AArch64_Q19:
1571
1.63k
      Reg = AArch64_Q20;
1572
1.63k
      break;
1573
4.43k
    case AArch64_Q20:
1574
4.43k
      Reg = AArch64_Q21;
1575
4.43k
      break;
1576
2.58k
    case AArch64_Q21:
1577
2.58k
      Reg = AArch64_Q22;
1578
2.58k
      break;
1579
3.77k
    case AArch64_Q22:
1580
3.77k
      Reg = AArch64_Q23;
1581
3.77k
      break;
1582
2.69k
    case AArch64_Q23:
1583
2.69k
      Reg = AArch64_Q24;
1584
2.69k
      break;
1585
1.67k
    case AArch64_Q24:
1586
1.67k
      Reg = AArch64_Q25;
1587
1.67k
      break;
1588
2.17k
    case AArch64_Q25:
1589
2.17k
      Reg = AArch64_Q26;
1590
2.17k
      break;
1591
1.16k
    case AArch64_Q26:
1592
1.16k
      Reg = AArch64_Q27;
1593
1.16k
      break;
1594
1.63k
    case AArch64_Q27:
1595
1.63k
      Reg = AArch64_Q28;
1596
1.63k
      break;
1597
1.05k
    case AArch64_Q28:
1598
1.05k
      Reg = AArch64_Q29;
1599
1.05k
      break;
1600
1.80k
    case AArch64_Q29:
1601
1.80k
      Reg = AArch64_Q30;
1602
1.80k
      break;
1603
1.38k
    case AArch64_Q30:
1604
1.38k
      Reg = AArch64_Q31;
1605
1.38k
      break;
1606
    // Vector lists can wrap around.
1607
2.87k
    case AArch64_Q31:
1608
2.87k
      Reg = AArch64_Q0;
1609
2.87k
      break;
1610
9.77k
    case AArch64_Z0:
1611
9.77k
      Reg = AArch64_Z1;
1612
9.77k
      break;
1613
7.25k
    case AArch64_Z1:
1614
7.25k
      Reg = AArch64_Z2;
1615
7.25k
      break;
1616
7.44k
    case AArch64_Z2:
1617
7.44k
      Reg = AArch64_Z3;
1618
7.44k
      break;
1619
1.76k
    case AArch64_Z3:
1620
1.76k
      Reg = AArch64_Z4;
1621
1.76k
      break;
1622
7.30k
    case AArch64_Z4:
1623
7.30k
      Reg = AArch64_Z5;
1624
7.30k
      break;
1625
4.74k
    case AArch64_Z5:
1626
4.74k
      Reg = AArch64_Z6;
1627
4.74k
      break;
1628
3.90k
    case AArch64_Z6:
1629
3.90k
      Reg = AArch64_Z7;
1630
3.90k
      break;
1631
2.37k
    case AArch64_Z7:
1632
2.37k
      Reg = AArch64_Z8;
1633
2.37k
      break;
1634
5.39k
    case AArch64_Z8:
1635
5.39k
      Reg = AArch64_Z9;
1636
5.39k
      break;
1637
5.37k
    case AArch64_Z9:
1638
5.37k
      Reg = AArch64_Z10;
1639
5.37k
      break;
1640
4.76k
    case AArch64_Z10:
1641
4.76k
      Reg = AArch64_Z11;
1642
4.76k
      break;
1643
2.84k
    case AArch64_Z11:
1644
2.84k
      Reg = AArch64_Z12;
1645
2.84k
      break;
1646
2.92k
    case AArch64_Z12:
1647
2.92k
      Reg = AArch64_Z13;
1648
2.92k
      break;
1649
2.39k
    case AArch64_Z13:
1650
2.39k
      Reg = AArch64_Z14;
1651
2.39k
      break;
1652
3.61k
    case AArch64_Z14:
1653
3.61k
      Reg = AArch64_Z15;
1654
3.61k
      break;
1655
2.23k
    case AArch64_Z15:
1656
2.23k
      Reg = AArch64_Z16;
1657
2.23k
      break;
1658
2.38k
    case AArch64_Z16:
1659
2.38k
      Reg = AArch64_Z17;
1660
2.38k
      break;
1661
1.15k
    case AArch64_Z17:
1662
1.15k
      Reg = AArch64_Z18;
1663
1.15k
      break;
1664
1.61k
    case AArch64_Z18:
1665
1.61k
      Reg = AArch64_Z19;
1666
1.61k
      break;
1667
1.07k
    case AArch64_Z19:
1668
1.07k
      Reg = AArch64_Z20;
1669
1.07k
      break;
1670
3.93k
    case AArch64_Z20:
1671
3.93k
      Reg = AArch64_Z21;
1672
3.93k
      break;
1673
2.12k
    case AArch64_Z21:
1674
2.12k
      Reg = AArch64_Z22;
1675
2.12k
      break;
1676
2.12k
    case AArch64_Z22:
1677
2.12k
      Reg = AArch64_Z23;
1678
2.12k
      break;
1679
499
    case AArch64_Z23:
1680
499
      Reg = AArch64_Z24;
1681
499
      break;
1682
1.99k
    case AArch64_Z24:
1683
1.99k
      Reg = AArch64_Z25;
1684
1.99k
      break;
1685
1.44k
    case AArch64_Z25:
1686
1.44k
      Reg = AArch64_Z26;
1687
1.44k
      break;
1688
1.69k
    case AArch64_Z26:
1689
1.69k
      Reg = AArch64_Z27;
1690
1.69k
      break;
1691
625
    case AArch64_Z27:
1692
625
      Reg = AArch64_Z28;
1693
625
      break;
1694
894
    case AArch64_Z28:
1695
894
      Reg = AArch64_Z29;
1696
894
      break;
1697
1.23k
    case AArch64_Z29:
1698
1.23k
      Reg = AArch64_Z30;
1699
1.23k
      break;
1700
2.33k
    case AArch64_Z30:
1701
2.33k
      Reg = AArch64_Z31;
1702
2.33k
      break;
1703
    // Vector lists can wrap around.
1704
1.36k
    case AArch64_Z31:
1705
1.36k
      Reg = AArch64_Z0;
1706
1.36k
      break;
1707
22
    case AArch64_P0:
1708
22
      Reg = AArch64_P1;
1709
22
      break;
1710
78
    case AArch64_P1:
1711
78
      Reg = AArch64_P2;
1712
78
      break;
1713
172
    case AArch64_P2:
1714
172
      Reg = AArch64_P3;
1715
172
      break;
1716
42
    case AArch64_P3:
1717
42
      Reg = AArch64_P4;
1718
42
      break;
1719
72
    case AArch64_P4:
1720
72
      Reg = AArch64_P5;
1721
72
      break;
1722
38
    case AArch64_P5:
1723
38
      Reg = AArch64_P6;
1724
38
      break;
1725
66
    case AArch64_P6:
1726
66
      Reg = AArch64_P7;
1727
66
      break;
1728
22
    case AArch64_P7:
1729
22
      Reg = AArch64_P8;
1730
22
      break;
1731
2
    case AArch64_P8:
1732
2
      Reg = AArch64_P9;
1733
2
      break;
1734
6
    case AArch64_P9:
1735
6
      Reg = AArch64_P10;
1736
6
      break;
1737
2
    case AArch64_P10:
1738
2
      Reg = AArch64_P11;
1739
2
      break;
1740
4
    case AArch64_P11:
1741
4
      Reg = AArch64_P12;
1742
4
      break;
1743
22
    case AArch64_P12:
1744
22
      Reg = AArch64_P13;
1745
22
      break;
1746
92
    case AArch64_P13:
1747
92
      Reg = AArch64_P14;
1748
92
      break;
1749
130
    case AArch64_P14:
1750
130
      Reg = AArch64_P15;
1751
130
      break;
1752
    // Vector lists can wrap around.
1753
36
    case AArch64_P15:
1754
36
      Reg = AArch64_P0;
1755
36
      break;
1756
156k
    }
1757
156k
  }
1758
98.9k
  return Reg;
1759
98.9k
}
1760
1761
#define DEFINE_printGPRSeqPairsClassOperand(size) \
1762
  void CONCAT(printGPRSeqPairsClassOperand, \
1763
        size)(MCInst * MI, unsigned OpNum, SStream *O) \
1764
1.37k
  { \
1765
1.37k
    AArch64_add_cs_detail_1( \
1766
1.37k
      MI, \
1767
1.37k
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1768
1.37k
             size), \
1769
1.37k
      OpNum, size); \
1770
1.37k
    CS_ASSERT_RET((size == 64 || size == 32) && \
1771
1.37k
           "Template parameter must be either 32 or 64"); \
1772
1.37k
    unsigned Reg = \
1773
1.37k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1774
1.37k
\
1775
1.37k
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1776
1.37k
                 AArch64_sube64; \
1777
1.37k
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1778
1.37k
                 AArch64_subo64; \
1779
1.37k
\
1780
1.37k
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1781
1.37k
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1782
1.37k
    printRegName(O, Even); \
1783
1.37k
    SStream_concat0(O, ", "); \
1784
1.37k
    printRegName(O, Odd); \
1785
1.37k
  }
printGPRSeqPairsClassOperand_32
Line
Count
Source
1764
76
  { \
1765
76
    AArch64_add_cs_detail_1( \
1766
76
      MI, \
1767
76
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1768
76
             size), \
1769
76
      OpNum, size); \
1770
76
    CS_ASSERT_RET((size == 64 || size == 32) && \
1771
76
           "Template parameter must be either 32 or 64"); \
1772
76
    unsigned Reg = \
1773
76
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1774
76
\
1775
76
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1776
76
                 AArch64_sube64; \
1777
76
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1778
76
                 AArch64_subo64; \
1779
76
\
1780
76
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1781
76
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1782
76
    printRegName(O, Even); \
1783
76
    SStream_concat0(O, ", "); \
1784
76
    printRegName(O, Odd); \
1785
76
  }
printGPRSeqPairsClassOperand_64
Line
Count
Source
1764
1.30k
  { \
1765
1.30k
    AArch64_add_cs_detail_1( \
1766
1.30k
      MI, \
1767
1.30k
      CONCAT(AArch64_OP_GROUP_GPRSeqPairsClassOperand, \
1768
1.30k
             size), \
1769
1.30k
      OpNum, size); \
1770
1.30k
    CS_ASSERT_RET((size == 64 || size == 32) && \
1771
1.30k
           "Template parameter must be either 32 or 64"); \
1772
1.30k
    unsigned Reg = \
1773
1.30k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1774
1.30k
\
1775
1.30k
    unsigned Sube = (size == 32) ? AArch64_sube32 : \
1776
1.30k
                 AArch64_sube64; \
1777
1.30k
    unsigned Subo = (size == 32) ? AArch64_subo32 : \
1778
1.30k
                 AArch64_subo64; \
1779
1.30k
\
1780
1.30k
    unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube); \
1781
1.30k
    unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo); \
1782
1.30k
    printRegName(O, Even); \
1783
1.30k
    SStream_concat0(O, ", "); \
1784
1.30k
    printRegName(O, Odd); \
1785
1.30k
  }
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
7.52k
  { \
1793
7.52k
    AArch64_add_cs_detail_1(MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1794
7.52k
            OpNum, Scale); \
1795
7.52k
    printInt64(O, Scale *MCOperand_getImm( \
1796
7.52k
              MCInst_getOperand(MI, (OpNum)))); \
1797
7.52k
  }
printMatrixIndex_8
Line
Count
Source
1792
311
  { \
1793
311
    AArch64_add_cs_detail_1(MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1794
311
            OpNum, Scale); \
1795
311
    printInt64(O, Scale *MCOperand_getImm( \
1796
311
              MCInst_getOperand(MI, (OpNum)))); \
1797
311
  }
Unexecuted instantiation: printMatrixIndex_0
printMatrixIndex_1
Line
Count
Source
1792
7.21k
  { \
1793
7.21k
    AArch64_add_cs_detail_1(MI, CONCAT(AArch64_OP_GROUP_MatrixIndex, Scale), \
1794
7.21k
            OpNum, Scale); \
1795
7.21k
    printInt64(O, Scale *MCOperand_getImm( \
1796
7.21k
              MCInst_getOperand(MI, (OpNum)))); \
1797
7.21k
  }
1798
DEFINE_printMatrixIndex(8);
1799
DEFINE_printMatrixIndex(0);
1800
DEFINE_printMatrixIndex(1);
1801
1802
void printMatrixTileList(MCInst *MI, unsigned OpNum, SStream *O)
1803
326
{
1804
326
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MatrixTileList, OpNum);
1805
326
  unsigned MaxRegs = 8;
1806
326
  unsigned RegMask = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1807
1808
326
  unsigned NumRegs = 0;
1809
2.93k
  for (unsigned I = 0; I < MaxRegs; ++I)
1810
2.60k
    if ((RegMask & (1 << I)) != 0)
1811
1.43k
      ++NumRegs;
1812
1813
326
  SStream_concat0(O, "{");
1814
326
  unsigned Printed = 0;
1815
2.93k
  for (unsigned I = 0; I < MaxRegs; ++I) {
1816
2.60k
    unsigned Reg = RegMask & (1 << I);
1817
2.60k
    if (Reg == 0)
1818
1.17k
      continue;
1819
1.43k
    printRegName(O, AArch64_ZAD0 + I);
1820
1.43k
    if (Printed + 1 != NumRegs)
1821
1.11k
      SStream_concat0(O, ", ");
1822
1.43k
    ++Printed;
1823
1.43k
  }
1824
326
  SStream_concat0(O, "}");
1825
326
}
1826
1827
void printVectorList(MCInst *MI, unsigned OpNum, SStream *O,
1828
         const char *LayoutSuffix)
1829
45.3k
{
1830
45.3k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
1831
1832
45.3k
  SStream_concat0(O, "{ ");
1833
1834
  // Work out how many registers there are in the list (if there is an actual
1835
  // list).
1836
45.3k
  unsigned NumRegs = 1;
1837
45.3k
  if (MCRegisterClass_contains(
1838
45.3k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_DDRegClassID),
1839
45.3k
        Reg) ||
1840
45.3k
      MCRegisterClass_contains(
1841
45.0k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPR2RegClassID),
1842
45.0k
        Reg) ||
1843
45.3k
      MCRegisterClass_contains(
1844
37.0k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_QQRegClassID),
1845
37.0k
        Reg) ||
1846
45.3k
      MCRegisterClass_contains(
1847
31.5k
        MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPR2RegClassID),
1848
31.5k
        Reg) ||
1849
45.3k
      MCRegisterClass_contains(
1850
31.1k
        MCRegisterInfo_getRegClass(MI->MRI,
1851
31.1k
                 AArch64_ZPR2StridedRegClassID),
1852
31.1k
        Reg))
1853
15.9k
    NumRegs = 2;
1854
29.4k
  else if (MCRegisterClass_contains(
1855
29.4k
       MCRegisterInfo_getRegClass(MI->MRI,
1856
29.4k
                AArch64_DDDRegClassID),
1857
29.4k
       Reg) ||
1858
29.4k
     MCRegisterClass_contains(
1859
28.2k
       MCRegisterInfo_getRegClass(MI->MRI,
1860
28.2k
                AArch64_ZPR3RegClassID),
1861
28.2k
       Reg) ||
1862
29.4k
     MCRegisterClass_contains(
1863
28.0k
       MCRegisterInfo_getRegClass(MI->MRI,
1864
28.0k
                AArch64_QQQRegClassID),
1865
28.0k
       Reg))
1866
5.48k
    NumRegs = 3;
1867
23.9k
  else if (MCRegisterClass_contains(
1868
23.9k
       MCRegisterInfo_getRegClass(MI->MRI,
1869
23.9k
                AArch64_DDDDRegClassID),
1870
23.9k
       Reg) ||
1871
23.9k
     MCRegisterClass_contains(
1872
23.3k
       MCRegisterInfo_getRegClass(MI->MRI,
1873
23.3k
                AArch64_ZPR4RegClassID),
1874
23.3k
       Reg) ||
1875
23.9k
     MCRegisterClass_contains(
1876
17.3k
       MCRegisterInfo_getRegClass(MI->MRI,
1877
17.3k
                AArch64_QQQQRegClassID),
1878
17.3k
       Reg) ||
1879
23.9k
     MCRegisterClass_contains(
1880
12.2k
       MCRegisterInfo_getRegClass(
1881
12.2k
         MI->MRI, AArch64_ZPR4StridedRegClassID),
1882
12.2k
       Reg))
1883
12.5k
    NumRegs = 4;
1884
1885
45.3k
  unsigned Stride = 1;
1886
45.3k
  if (MCRegisterClass_contains(
1887
45.3k
        MCRegisterInfo_getRegClass(MI->MRI,
1888
45.3k
                 AArch64_ZPR2StridedRegClassID),
1889
45.3k
        Reg))
1890
1.73k
    Stride = 8;
1891
43.6k
  else if (MCRegisterClass_contains(
1892
43.6k
       MCRegisterInfo_getRegClass(
1893
43.6k
         MI->MRI, AArch64_ZPR4StridedRegClassID),
1894
43.6k
       Reg))
1895
778
    Stride = 4;
1896
1897
  // Now forget about the list and find out what the first register is.
1898
45.3k
  if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0))
1899
2.25k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_dsub0);
1900
43.1k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0))
1901
14.7k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_qsub0);
1902
28.4k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0))
1903
16.6k
    Reg = MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_zsub0);
1904
11.8k
  else if (MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_psub0))
1905
394
    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
45.3k
  if (MCRegisterClass_contains(MCRegisterInfo_getRegClass(
1910
45.3k
               MI->MRI, AArch64_FPR64RegClassID),
1911
45.3k
             Reg)) {
1912
2.32k
    const MCRegisterClass *FPR128RC = MCRegisterInfo_getRegClass(
1913
2.32k
      MI->MRI, AArch64_FPR128RegClassID);
1914
2.32k
    Reg = MCRegisterInfo_getMatchingSuperReg(
1915
2.32k
      MI->MRI, Reg, AArch64_dsub, FPR128RC);
1916
2.32k
  }
1917
1918
45.3k
  if ((MCRegisterClass_contains(
1919
45.3k
         MCRegisterInfo_getRegClass(MI->MRI, AArch64_ZPRRegClassID),
1920
45.3k
         Reg) ||
1921
45.3k
       MCRegisterClass_contains(
1922
21.2k
         MCRegisterInfo_getRegClass(MI->MRI, AArch64_PPRRegClassID),
1923
21.2k
         Reg)) &&
1924
45.3k
      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
45.3k
      Reg < getNextVectorRegister(Reg, NumRegs - 1)) {
1928
14.0k
    printRegName(O, Reg);
1929
14.0k
    SStream_concat0(O, LayoutSuffix);
1930
14.0k
    if (NumRegs > 1) {
1931
      // Set of two sve registers should be separated by ','
1932
14.0k
      const char *split_char = NumRegs == 2 ? ", " : " - ";
1933
14.0k
      SStream_concat0(O, split_char);
1934
14.0k
      printRegName(O,
1935
14.0k
             (getNextVectorRegister(Reg, NumRegs - 1)));
1936
14.0k
      SStream_concat0(O, LayoutSuffix);
1937
14.0k
    }
1938
31.3k
  } else {
1939
101k
    for (unsigned i = 0; i < NumRegs;
1940
70.3k
         ++i, Reg = getNextVectorRegister(Reg, Stride)) {
1941
      // wrap-around sve register
1942
70.3k
      if (MCRegisterClass_contains(
1943
70.3k
            MCRegisterInfo_getRegClass(
1944
70.3k
              MI->MRI, AArch64_ZPRRegClassID),
1945
70.3k
            Reg) ||
1946
70.3k
          MCRegisterClass_contains(
1947
54.6k
            MCRegisterInfo_getRegClass(
1948
54.6k
              MI->MRI, AArch64_PPRRegClassID),
1949
54.6k
            Reg))
1950
15.6k
        printRegName(O, Reg);
1951
54.6k
      else
1952
54.6k
        printRegNameAlt(O, Reg, AArch64_vreg);
1953
70.3k
      SStream_concat0(O, LayoutSuffix);
1954
70.3k
      if (i + 1 != NumRegs)
1955
39.0k
        SStream_concat0(O, ", ");
1956
70.3k
    }
1957
31.3k
  }
1958
45.3k
  SStream_concat0(O, " }");
1959
45.3k
}
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
45.3k
  { \
1972
45.3k
    AArch64_add_cs_detail_2( \
1973
45.3k
      MI, \
1974
45.3k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
45.3k
              NumLanes), \
1976
45.3k
             LaneKind), \
1977
45.3k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
45.3k
    if (CHAR(LaneKind) == '0') { \
1979
72
      printVectorList(MI, OpNum, O, ""); \
1980
72
      return; \
1981
72
    } \
1982
45.3k
    char Suffix[32]; \
1983
45.3k
    if (NumLanes) \
1984
45.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
6.02k
            CHAR(LaneKind)); \
1986
45.3k
    else \
1987
45.3k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
39.2k
            CHAR(LaneKind)); \
1989
45.3k
\
1990
45.3k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
45.3k
  }
printTypedVectorList_0_b
Line
Count
Source
1971
9.10k
  { \
1972
9.10k
    AArch64_add_cs_detail_2( \
1973
9.10k
      MI, \
1974
9.10k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
9.10k
              NumLanes), \
1976
9.10k
             LaneKind), \
1977
9.10k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
9.10k
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
9.10k
    char Suffix[32]; \
1983
9.10k
    if (NumLanes) \
1984
9.10k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
0
            CHAR(LaneKind)); \
1986
9.10k
    else \
1987
9.10k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
9.10k
            CHAR(LaneKind)); \
1989
9.10k
\
1990
9.10k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
9.10k
  }
printTypedVectorList_0_d
Line
Count
Source
1971
13.8k
  { \
1972
13.8k
    AArch64_add_cs_detail_2( \
1973
13.8k
      MI, \
1974
13.8k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
13.8k
              NumLanes), \
1976
13.8k
             LaneKind), \
1977
13.8k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
13.8k
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
13.8k
    char Suffix[32]; \
1983
13.8k
    if (NumLanes) \
1984
13.8k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
0
            CHAR(LaneKind)); \
1986
13.8k
    else \
1987
13.8k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
13.8k
            CHAR(LaneKind)); \
1989
13.8k
\
1990
13.8k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
13.8k
  }
printTypedVectorList_0_h
Line
Count
Source
1971
7.99k
  { \
1972
7.99k
    AArch64_add_cs_detail_2( \
1973
7.99k
      MI, \
1974
7.99k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
7.99k
              NumLanes), \
1976
7.99k
             LaneKind), \
1977
7.99k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
7.99k
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
7.99k
    char Suffix[32]; \
1983
7.99k
    if (NumLanes) \
1984
7.99k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
0
            CHAR(LaneKind)); \
1986
7.99k
    else \
1987
7.99k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
7.99k
            CHAR(LaneKind)); \
1989
7.99k
\
1990
7.99k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
7.99k
  }
printTypedVectorList_0_s
Line
Count
Source
1971
7.29k
  { \
1972
7.29k
    AArch64_add_cs_detail_2( \
1973
7.29k
      MI, \
1974
7.29k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
7.29k
              NumLanes), \
1976
7.29k
             LaneKind), \
1977
7.29k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
7.29k
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
7.29k
    char Suffix[32]; \
1983
7.29k
    if (NumLanes) \
1984
7.29k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
0
            CHAR(LaneKind)); \
1986
7.29k
    else \
1987
7.29k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
7.29k
            CHAR(LaneKind)); \
1989
7.29k
\
1990
7.29k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
7.29k
  }
printTypedVectorList_0_q
Line
Count
Source
1971
1.02k
  { \
1972
1.02k
    AArch64_add_cs_detail_2( \
1973
1.02k
      MI, \
1974
1.02k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
1.02k
              NumLanes), \
1976
1.02k
             LaneKind), \
1977
1.02k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
1.02k
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
1.02k
    char Suffix[32]; \
1983
1.02k
    if (NumLanes) \
1984
1.02k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
0
            CHAR(LaneKind)); \
1986
1.02k
    else \
1987
1.02k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
1.02k
            CHAR(LaneKind)); \
1989
1.02k
\
1990
1.02k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
1.02k
  }
printTypedVectorList_16_b
Line
Count
Source
1971
1.77k
  { \
1972
1.77k
    AArch64_add_cs_detail_2( \
1973
1.77k
      MI, \
1974
1.77k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
1.77k
              NumLanes), \
1976
1.77k
             LaneKind), \
1977
1.77k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
1.77k
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
1.77k
    char Suffix[32]; \
1983
1.77k
    if (NumLanes) \
1984
1.77k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
1.77k
            CHAR(LaneKind)); \
1986
1.77k
    else \
1987
1.77k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
1.77k
\
1990
1.77k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
1.77k
  }
printTypedVectorList_1_d
Line
Count
Source
1971
724
  { \
1972
724
    AArch64_add_cs_detail_2( \
1973
724
      MI, \
1974
724
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
724
              NumLanes), \
1976
724
             LaneKind), \
1977
724
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
724
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
724
    char Suffix[32]; \
1983
724
    if (NumLanes) \
1984
724
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
724
            CHAR(LaneKind)); \
1986
724
    else \
1987
724
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
724
\
1990
724
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
724
  }
printTypedVectorList_2_d
Line
Count
Source
1971
1.08k
  { \
1972
1.08k
    AArch64_add_cs_detail_2( \
1973
1.08k
      MI, \
1974
1.08k
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
1.08k
              NumLanes), \
1976
1.08k
             LaneKind), \
1977
1.08k
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
1.08k
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
1.08k
    char Suffix[32]; \
1983
1.08k
    if (NumLanes) \
1984
1.08k
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
1.08k
            CHAR(LaneKind)); \
1986
1.08k
    else \
1987
1.08k
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
1.08k
\
1990
1.08k
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
1.08k
  }
printTypedVectorList_2_s
Line
Count
Source
1971
596
  { \
1972
596
    AArch64_add_cs_detail_2( \
1973
596
      MI, \
1974
596
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
596
              NumLanes), \
1976
596
             LaneKind), \
1977
596
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
596
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
596
    char Suffix[32]; \
1983
596
    if (NumLanes) \
1984
596
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
596
            CHAR(LaneKind)); \
1986
596
    else \
1987
596
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
596
\
1990
596
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
596
  }
printTypedVectorList_4_h
Line
Count
Source
1971
713
  { \
1972
713
    AArch64_add_cs_detail_2( \
1973
713
      MI, \
1974
713
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
713
              NumLanes), \
1976
713
             LaneKind), \
1977
713
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
713
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
713
    char Suffix[32]; \
1983
713
    if (NumLanes) \
1984
713
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
713
            CHAR(LaneKind)); \
1986
713
    else \
1987
713
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
713
\
1990
713
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
713
  }
printTypedVectorList_4_s
Line
Count
Source
1971
325
  { \
1972
325
    AArch64_add_cs_detail_2( \
1973
325
      MI, \
1974
325
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
325
              NumLanes), \
1976
325
             LaneKind), \
1977
325
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
325
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
325
    char Suffix[32]; \
1983
325
    if (NumLanes) \
1984
325
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
325
            CHAR(LaneKind)); \
1986
325
    else \
1987
325
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
325
\
1990
325
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
325
  }
printTypedVectorList_8_b
Line
Count
Source
1971
287
  { \
1972
287
    AArch64_add_cs_detail_2( \
1973
287
      MI, \
1974
287
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
287
              NumLanes), \
1976
287
             LaneKind), \
1977
287
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
287
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
287
    char Suffix[32]; \
1983
287
    if (NumLanes) \
1984
287
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
287
            CHAR(LaneKind)); \
1986
287
    else \
1987
287
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
287
\
1990
287
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
287
  }
printTypedVectorList_8_h
Line
Count
Source
1971
525
  { \
1972
525
    AArch64_add_cs_detail_2( \
1973
525
      MI, \
1974
525
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
525
              NumLanes), \
1976
525
             LaneKind), \
1977
525
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
525
    if (CHAR(LaneKind) == '0') { \
1979
0
      printVectorList(MI, OpNum, O, ""); \
1980
0
      return; \
1981
0
    } \
1982
525
    char Suffix[32]; \
1983
525
    if (NumLanes) \
1984
525
      cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, \
1985
525
            CHAR(LaneKind)); \
1986
525
    else \
1987
525
      cs_snprintf(Suffix, sizeof(Suffix), ".%c", \
1988
0
            CHAR(LaneKind)); \
1989
525
\
1990
525
    printVectorList(MI, OpNum, O, ((const char *)&Suffix)); \
1991
525
  }
printTypedVectorList_0_0
Line
Count
Source
1971
72
  { \
1972
72
    AArch64_add_cs_detail_2( \
1973
72
      MI, \
1974
72
      CONCAT(CONCAT(AArch64_OP_GROUP_TypedVectorList, \
1975
72
              NumLanes), \
1976
72
             LaneKind), \
1977
72
      OpNum, NumLanes, CHAR(LaneKind)); \
1978
72
    if (CHAR(LaneKind) == '0') { \
1979
72
      printVectorList(MI, OpNum, O, ""); \
1980
72
      return; \
1981
72
    } \
1982
72
    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
27.9k
  { \
2011
27.9k
    AArch64_add_cs_detail_1( \
2012
27.9k
      MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \
2013
27.9k
      OpNum, Scale); \
2014
27.9k
    SStream_concat(O, "%s", "["); \
2015
27.9k
    printUInt64(O, Scale *MCOperand_getImm( \
2016
27.9k
               MCInst_getOperand(MI, (OpNum)))); \
2017
27.9k
    SStream_concat0(O, "]"); \
2018
27.9k
  }
printVectorIndex_1
Line
Count
Source
2010
27.9k
  { \
2011
27.9k
    AArch64_add_cs_detail_1( \
2012
27.9k
      MI, CONCAT(AArch64_OP_GROUP_VectorIndex, Scale), \
2013
27.9k
      OpNum, Scale); \
2014
27.9k
    SStream_concat(O, "%s", "["); \
2015
27.9k
    printUInt64(O, Scale *MCOperand_getImm( \
2016
27.9k
               MCInst_getOperand(MI, (OpNum)))); \
2017
27.9k
    SStream_concat0(O, "]"); \
2018
27.9k
  }
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
10.4k
{
2024
10.4k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AlignedLabel, OpNum);
2025
10.4k
  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
10.4k
  if (MCOperand_isImm(Op)) {
2030
10.2k
    SStream_concat0(O, markup("<imm:"));
2031
10.2k
    int64_t Offset = MCOperand_getImm(Op) * 4;
2032
10.2k
    if (MI->csh->PrintBranchImmAsAddress)
2033
10.2k
      printUInt64(O, (Address + Offset));
2034
0
    else {
2035
0
      printUInt64Bang(O, (Offset));
2036
0
    }
2037
10.2k
    SStream_concat0(O, markup(">"));
2038
10.2k
    return;
2039
10.2k
  }
2040
2041
198
  printUInt64Bang(O, MCOperand_getImm(Op));
2042
198
}
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
4.45k
void printAdrAdrpLabel(MCInst *MI, uint64_t Address, unsigned OpNum, SStream *O) {
2089
4.45k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AdrAdrpLabel, OpNum);
2090
4.45k
  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
4.45k
  if (MCOperand_isImm(Op)) {
2095
4.45k
    int64_t Offset = MCOperand_getImm(Op);
2096
4.45k
    if (MCInst_getOpcode(MI) == AArch64_ADRP) {
2097
2.21k
      Offset = Offset * 4096;
2098
2.21k
      Address = Address & -4096;
2099
2.21k
    }
2100
4.45k
    SStream_concat0(O, markup(">"));
2101
4.45k
    if (MI->csh->PrintBranchImmAsAddress)
2102
4.45k
      printUInt64(O, (Address + Offset));
2103
0
    else {
2104
0
      printUInt64Bang(O, Offset);
2105
0
    }
2106
4.45k
    SStream_concat0(O, markup(">"));
2107
4.45k
    return;
2108
4.45k
  }
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
31
{
2118
31
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_AppleSysBarrierOption, OpNo);
2119
31
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2120
31
  switch (Val) {
2121
13
  default:
2122
13
    SStream_concat0(O, "<undefined>");
2123
13
    break;
2124
1
  case 0:
2125
1
    SStream_concat0(O, "osh");
2126
1
    break;
2127
9
  case 1:
2128
9
    SStream_concat0(O, "nsh");
2129
9
    break;
2130
0
  case 2:
2131
0
    SStream_concat0(O, "ish");
2132
0
    break;
2133
8
  case 3:
2134
8
    SStream_concat0(O, "sy");
2135
8
    break;
2136
31
  }
2137
31
}
2138
2139
void printBarrierOption(MCInst *MI, unsigned OpNo, SStream *O)
2140
255
{
2141
255
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarrierOption, OpNo);
2142
255
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2143
255
  unsigned Opcode = MCInst_getOpcode(MI);
2144
2145
255
  const char *Name;
2146
255
  if (Opcode == AArch64_ISB) {
2147
79
    const AArch64ISB_ISB *ISB = AArch64ISB_lookupISBByEncoding(Val);
2148
79
    Name = ISB ? ISB->Name : "";
2149
176
  } else if (Opcode == AArch64_TSB) {
2150
18
    const AArch64TSB_TSB *TSB = AArch64TSB_lookupTSBByEncoding(Val);
2151
18
    Name = TSB ? TSB->Name : "";
2152
158
  } else {
2153
158
    const AArch64DB_DB *DB = AArch64DB_lookupDBByEncoding(Val);
2154
158
    Name = DB ? DB->Name : "";
2155
158
  }
2156
255
  if (Name[0] != '\0')
2157
165
    SStream_concat0(O, Name);
2158
90
  else {
2159
90
    SStream_concat(O, "%s", markup("<imm:"));
2160
90
    printUInt32Bang(O, Val);
2161
90
    SStream_concat0(O, markup(">"));
2162
90
  }
2163
255
}
2164
2165
void printBarriernXSOption(MCInst *MI, unsigned OpNo, SStream *O)
2166
79
{
2167
79
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_BarriernXSOption, OpNo);
2168
79
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2169
2170
79
  const char *Name;
2171
79
  const AArch64DBnXS_DBnXS *DB = AArch64DBnXS_lookupDBnXSByEncoding(Val);
2172
79
  Name = DB ? DB->Name : "";
2173
2174
79
  if (Name[0] != '\0')
2175
79
    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
79
}
2181
2182
static bool isValidSysReg(const AArch64SysReg_SysReg *Reg, bool Read,
2183
        unsigned mode)
2184
5.51k
{
2185
5.51k
  return (Reg && (Read ? Reg->Readable : Reg->Writeable) &&
2186
5.51k
    AArch64_testFeatureList(mode, Reg->FeaturesRequired));
2187
5.51k
}
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
4.55k
{
2198
4.55k
  const AArch64SysReg_SysReg *Reg =
2199
4.55k
    AArch64SysReg_lookupSysRegByEncoding(Val);
2200
2201
4.55k
  if (Reg && !isValidSysReg(Reg, Read, mode))
2202
742
    Reg = AArch64SysReg_lookupSysRegByName(Reg->AltName);
2203
2204
4.55k
  return Reg;
2205
4.55k
}
2206
2207
void printMRSSystemRegister(MCInst *MI, unsigned OpNo, SStream *O)
2208
1.16k
{
2209
1.16k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MRSSystemRegister, OpNo);
2210
1.16k
  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.16k
  if (Val == AARCH64_SYSREG_DBGDTRRX_EL0) {
2216
67
    SStream_concat0(O, "DBGDTRRX_EL0");
2217
67
    return;
2218
67
  }
2219
2220
  // Horrible hack for two different registers having the same encoding.
2221
1.09k
  if (Val == AARCH64_SYSREG_TRCEXTINSELR) {
2222
12
    SStream_concat0(O, "TRCEXTINSELR");
2223
12
    return;
2224
12
  }
2225
2226
1.08k
  const AArch64SysReg_SysReg *Reg =
2227
1.08k
    lookupSysReg(Val, true /*Read*/, MI->csh->mode);
2228
2229
1.08k
  if (isValidSysReg(Reg, true /*Read*/, MI->csh->mode))
2230
108
    SStream_concat0(O, Reg->Name);
2231
978
  else {
2232
978
    char result[AARCH64_GRS_LEN + 1] = { 0 };
2233
978
    AArch64SysReg_genericRegisterString(Val, result);
2234
978
    SStream_concat0(O, result);
2235
978
  }
2236
1.08k
}
2237
2238
void printMSRSystemRegister(MCInst *MI, unsigned OpNo, SStream *O)
2239
3.59k
{
2240
3.59k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_MSRSystemRegister, OpNo);
2241
3.59k
  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.59k
  if (Val == AARCH64_SYSREG_DBGDTRTX_EL0) {
2247
103
    SStream_concat0(O, "DBGDTRTX_EL0");
2248
103
    return;
2249
103
  }
2250
2251
  // Horrible hack for two different registers having the same encoding.
2252
3.48k
  if (Val == AARCH64_SYSREG_TRCEXTINSELR) {
2253
23
    SStream_concat0(O, "TRCEXTINSELR");
2254
23
    return;
2255
23
  }
2256
2257
3.46k
  const AArch64SysReg_SysReg *Reg =
2258
3.46k
    lookupSysReg(Val, false /*Read*/, MI->csh->mode);
2259
2260
3.46k
  if (isValidSysReg(Reg, false /*Read*/, MI->csh->mode))
2261
115
    SStream_concat0(O, Reg->Name);
2262
3.35k
  else {
2263
3.35k
    char result[AARCH64_GRS_LEN + 1] = { 0 };
2264
3.35k
    AArch64SysReg_genericRegisterString(Val, result);
2265
3.35k
    SStream_concat0(O, result);
2266
3.35k
  }
2267
3.46k
}
2268
2269
void printSystemPStateField(MCInst *MI, unsigned OpNo, SStream *O)
2270
913
{
2271
913
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SystemPStateField, OpNo);
2272
913
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2273
2274
913
  const AArch64PState_PStateImm0_15 *PStateImm15 =
2275
913
    AArch64PState_lookupPStateImm0_15ByEncoding(Val);
2276
913
  const AArch64PState_PStateImm0_1 *PStateImm1 =
2277
913
    AArch64PState_lookupPStateImm0_1ByEncoding(Val);
2278
913
  if (PStateImm15 &&
2279
913
      AArch64_testFeatureList(MI->csh->mode,
2280
864
            PStateImm15->FeaturesRequired))
2281
864
    SStream_concat0(O, PStateImm15->Name);
2282
49
  else if (PStateImm1 &&
2283
49
     AArch64_testFeatureList(MI->csh->mode,
2284
49
           PStateImm1->FeaturesRequired))
2285
49
    SStream_concat0(O, PStateImm1->Name);
2286
0
  else {
2287
0
    printUInt32Bang(O, (Val));
2288
0
    SStream_concat1(O, '\0');
2289
0
  }
2290
913
}
2291
2292
void printSIMDType10Operand(MCInst *MI, unsigned OpNo, SStream *O)
2293
872
{
2294
872
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SIMDType10Operand, OpNo);
2295
872
  unsigned RawVal = MCOperand_getImm(MCInst_getOperand(MI, (OpNo)));
2296
872
  uint64_t Val = AArch64_AM_decodeAdvSIMDModImmType10(RawVal);
2297
872
  SStream_concat(O, "%s#%#016llx", markup("<imm:"), Val);
2298
872
  SStream_concat0(O, markup(">"));
2299
872
}
2300
2301
#define DEFINE_printComplexRotationOp(Angle, Remainder) \
2302
  static void CONCAT(printComplexRotationOp, CONCAT(Angle, Remainder))( \
2303
    MCInst * MI, unsigned OpNo, SStream *O) \
2304
2.05k
  { \
2305
2.05k
    AArch64_add_cs_detail_2( \
2306
2.05k
      MI, \
2307
2.05k
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2308
2.05k
              Angle), \
2309
2.05k
             Remainder), \
2310
2.05k
      OpNo, Angle, Remainder); \
2311
2.05k
    unsigned Val = \
2312
2.05k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2313
2.05k
    SStream_concat(O, "%s", markup("<imm:")); \
2314
2.05k
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2315
2.05k
    SStream_concat0(O, markup(">")); \
2316
2.05k
  }
AArch64InstPrinter.c:printComplexRotationOp_180_90
Line
Count
Source
2304
645
  { \
2305
645
    AArch64_add_cs_detail_2( \
2306
645
      MI, \
2307
645
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2308
645
              Angle), \
2309
645
             Remainder), \
2310
645
      OpNo, Angle, Remainder); \
2311
645
    unsigned Val = \
2312
645
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2313
645
    SStream_concat(O, "%s", markup("<imm:")); \
2314
645
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2315
645
    SStream_concat0(O, markup(">")); \
2316
645
  }
AArch64InstPrinter.c:printComplexRotationOp_90_0
Line
Count
Source
2304
1.40k
  { \
2305
1.40k
    AArch64_add_cs_detail_2( \
2306
1.40k
      MI, \
2307
1.40k
      CONCAT(CONCAT(AArch64_OP_GROUP_ComplexRotationOp, \
2308
1.40k
              Angle), \
2309
1.40k
             Remainder), \
2310
1.40k
      OpNo, Angle, Remainder); \
2311
1.40k
    unsigned Val = \
2312
1.40k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
2313
1.40k
    SStream_concat(O, "%s", markup("<imm:")); \
2314
1.40k
    SStream_concat(O, "#%d", (Val * Angle) + Remainder); \
2315
1.40k
    SStream_concat0(O, markup(">")); \
2316
1.40k
  }
2317
DEFINE_printComplexRotationOp(180, 90);
2318
DEFINE_printComplexRotationOp(90, 0);
2319
2320
void printSVEPattern(MCInst *MI, unsigned OpNum, SStream *O)
2321
4.96k
{
2322
4.96k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEPattern, OpNum);
2323
4.96k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
2324
4.96k
  const AArch64SVEPredPattern_SVEPREDPAT *Pat =
2325
4.96k
    AArch64SVEPredPattern_lookupSVEPREDPATByEncoding(Val);
2326
4.96k
  if (Pat)
2327
3.16k
    SStream_concat0(O, Pat->Name);
2328
1.80k
  else
2329
1.80k
    printUInt32Bang(O, Val);
2330
4.96k
}
2331
2332
void printSVEVecLenSpecifier(MCInst *MI, unsigned OpNum, SStream *O)
2333
425
{
2334
425
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SVEVecLenSpecifier, OpNum);
2335
425
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
2336
  // Pattern has only 1 bit
2337
425
  if (Val > 1)
2338
0
    CS_ASSERT_RET(0 && "Invalid vector length specifier");
2339
425
  const AArch64SVEVecLenSpecifier_SVEVECLENSPECIFIER *Pat =
2340
425
    AArch64SVEVecLenSpecifier_lookupSVEVECLENSPECIFIERByEncoding(
2341
425
      Val);
2342
425
  if (Pat)
2343
425
    SStream_concat0(O, Pat->Name);
2344
425
}
2345
2346
#define DEFINE_printSVERegOp(suffix) \
2347
  void CONCAT(printSVERegOp, suffix)(MCInst * MI, unsigned OpNum, \
2348
             SStream *O) \
2349
130k
  { \
2350
130k
    AArch64_add_cs_detail_1( \
2351
130k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2352
130k
      CHAR(suffix)); \
2353
130k
    switch (CHAR(suffix)) { \
2354
35.8k
    case '0': \
2355
56.5k
    case 'b': \
2356
82.1k
    case 'h': \
2357
106k
    case 's': \
2358
129k
    case 'd': \
2359
130k
    case 'q': \
2360
130k
      break; \
2361
129k
    default: \
2362
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2363
130k
    } \
2364
130k
\
2365
130k
    unsigned Reg = \
2366
130k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2367
130k
    printRegName(O, Reg); \
2368
130k
    if (CHAR(suffix) != '0') { \
2369
95.0k
      SStream_concat1(O, '.'); \
2370
95.0k
      SStream_concat1(O, CHAR(suffix)); \
2371
95.0k
    } \
2372
130k
  }
printSVERegOp_b
Line
Count
Source
2349
20.6k
  { \
2350
20.6k
    AArch64_add_cs_detail_1( \
2351
20.6k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2352
20.6k
      CHAR(suffix)); \
2353
20.6k
    switch (CHAR(suffix)) { \
2354
0
    case '0': \
2355
20.6k
    case 'b': \
2356
20.6k
    case 'h': \
2357
20.6k
    case 's': \
2358
20.6k
    case 'd': \
2359
20.6k
    case 'q': \
2360
20.6k
      break; \
2361
20.6k
    default: \
2362
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2363
20.6k
    } \
2364
20.6k
\
2365
20.6k
    unsigned Reg = \
2366
20.6k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2367
20.6k
    printRegName(O, Reg); \
2368
20.6k
    if (CHAR(suffix) != '0') { \
2369
20.6k
      SStream_concat1(O, '.'); \
2370
20.6k
      SStream_concat1(O, CHAR(suffix)); \
2371
20.6k
    } \
2372
20.6k
  }
printSVERegOp_d
Line
Count
Source
2349
23.0k
  { \
2350
23.0k
    AArch64_add_cs_detail_1( \
2351
23.0k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2352
23.0k
      CHAR(suffix)); \
2353
23.0k
    switch (CHAR(suffix)) { \
2354
0
    case '0': \
2355
0
    case 'b': \
2356
0
    case 'h': \
2357
0
    case 's': \
2358
23.0k
    case 'd': \
2359
23.0k
    case 'q': \
2360
23.0k
      break; \
2361
23.0k
    default: \
2362
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2363
23.0k
    } \
2364
23.0k
\
2365
23.0k
    unsigned Reg = \
2366
23.0k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2367
23.0k
    printRegName(O, Reg); \
2368
23.0k
    if (CHAR(suffix) != '0') { \
2369
23.0k
      SStream_concat1(O, '.'); \
2370
23.0k
      SStream_concat1(O, CHAR(suffix)); \
2371
23.0k
    } \
2372
23.0k
  }
printSVERegOp_h
Line
Count
Source
2349
25.6k
  { \
2350
25.6k
    AArch64_add_cs_detail_1( \
2351
25.6k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2352
25.6k
      CHAR(suffix)); \
2353
25.6k
    switch (CHAR(suffix)) { \
2354
0
    case '0': \
2355
0
    case 'b': \
2356
25.6k
    case 'h': \
2357
25.6k
    case 's': \
2358
25.6k
    case 'd': \
2359
25.6k
    case 'q': \
2360
25.6k
      break; \
2361
25.6k
    default: \
2362
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2363
25.6k
    } \
2364
25.6k
\
2365
25.6k
    unsigned Reg = \
2366
25.6k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2367
25.6k
    printRegName(O, Reg); \
2368
25.6k
    if (CHAR(suffix) != '0') { \
2369
25.6k
      SStream_concat1(O, '.'); \
2370
25.6k
      SStream_concat1(O, CHAR(suffix)); \
2371
25.6k
    } \
2372
25.6k
  }
printSVERegOp_s
Line
Count
Source
2349
24.6k
  { \
2350
24.6k
    AArch64_add_cs_detail_1( \
2351
24.6k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2352
24.6k
      CHAR(suffix)); \
2353
24.6k
    switch (CHAR(suffix)) { \
2354
0
    case '0': \
2355
0
    case 'b': \
2356
0
    case 'h': \
2357
24.6k
    case 's': \
2358
24.6k
    case 'd': \
2359
24.6k
    case 'q': \
2360
24.6k
      break; \
2361
24.6k
    default: \
2362
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2363
24.6k
    } \
2364
24.6k
\
2365
24.6k
    unsigned Reg = \
2366
24.6k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2367
24.6k
    printRegName(O, Reg); \
2368
24.6k
    if (CHAR(suffix) != '0') { \
2369
24.6k
      SStream_concat1(O, '.'); \
2370
24.6k
      SStream_concat1(O, CHAR(suffix)); \
2371
24.6k
    } \
2372
24.6k
  }
printSVERegOp_0
Line
Count
Source
2349
35.8k
  { \
2350
35.8k
    AArch64_add_cs_detail_1( \
2351
35.8k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2352
35.8k
      CHAR(suffix)); \
2353
35.8k
    switch (CHAR(suffix)) { \
2354
35.8k
    case '0': \
2355
35.8k
    case 'b': \
2356
35.8k
    case 'h': \
2357
35.8k
    case 's': \
2358
35.8k
    case 'd': \
2359
35.8k
    case 'q': \
2360
35.8k
      break; \
2361
35.8k
    default: \
2362
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2363
35.8k
    } \
2364
35.8k
\
2365
35.8k
    unsigned Reg = \
2366
35.8k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2367
35.8k
    printRegName(O, Reg); \
2368
35.8k
    if (CHAR(suffix) != '0') { \
2369
0
      SStream_concat1(O, '.'); \
2370
0
      SStream_concat1(O, CHAR(suffix)); \
2371
0
    } \
2372
35.8k
  }
printSVERegOp_q
Line
Count
Source
2349
1.13k
  { \
2350
1.13k
    AArch64_add_cs_detail_1( \
2351
1.13k
      MI, CONCAT(AArch64_OP_GROUP_SVERegOp, suffix), OpNum, \
2352
1.13k
      CHAR(suffix)); \
2353
1.13k
    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.13k
    case 'q': \
2360
1.13k
      break; \
2361
0
    default: \
2362
0
      CS_ASSERT_RET(0 && "Invalid kind specifier."); \
2363
1.13k
    } \
2364
1.13k
\
2365
1.13k
    unsigned Reg = \
2366
1.13k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2367
1.13k
    printRegName(O, Reg); \
2368
1.13k
    if (CHAR(suffix) != '0') { \
2369
1.13k
      SStream_concat1(O, '.'); \
2370
1.13k
      SStream_concat1(O, CHAR(suffix)); \
2371
1.13k
    } \
2372
1.13k
  }
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
1.42k
  { \
2383
1.42k
    printInt32Bang(O, Val); \
2384
1.42k
  }
printImmSVE_int16_t
Line
Count
Source
2382
760
  { \
2383
760
    printInt32Bang(O, Val); \
2384
760
  }
printImmSVE_int8_t
Line
Count
Source
2382
186
  { \
2383
186
    printInt32Bang(O, Val); \
2384
186
  }
printImmSVE_int32_t
Line
Count
Source
2382
475
  { \
2383
475
    printInt32Bang(O, Val); \
2384
475
  }
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.11k
  { \
2392
1.11k
    printUInt32Bang(O, Val); \
2393
1.11k
  }
printImmSVE_uint16_t
Line
Count
Source
2391
491
  { \
2392
491
    printUInt32Bang(O, Val); \
2393
491
  }
printImmSVE_uint8_t
Line
Count
Source
2391
70
  { \
2392
70
    printUInt32Bang(O, Val); \
2393
70
  }
printImmSVE_uint32_t
Line
Count
Source
2391
551
  { \
2392
551
    printUInt32Bang(O, Val); \
2393
551
  }
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
438
  { \
2401
438
    printInt64Bang(O, Val); \
2402
438
  }
2403
DECLARE_printImmSVE_S64(int64_t);
2404
2405
#define DECLARE_printImmSVE_U64(T) \
2406
  void CONCAT(printImmSVE, T)(T Val, SStream * O) \
2407
327
  { \
2408
327
    printUInt64Bang(O, Val); \
2409
327
  }
2410
DECLARE_printImmSVE_U64(uint64_t);
2411
2412
#define DEFINE_isSignedType(T) \
2413
  static inline bool CONCAT(isSignedType, T)() \
2414
2.59k
  { \
2415
2.59k
    return CHAR(T) == 'i'; \
2416
2.59k
  }
AArch64InstPrinter.c:isSignedType_int16_t
Line
Count
Source
2414
516
  { \
2415
516
    return CHAR(T) == 'i'; \
2416
516
  }
AArch64InstPrinter.c:isSignedType_int8_t
Line
Count
Source
2414
186
  { \
2415
186
    return CHAR(T) == 'i'; \
2416
186
  }
AArch64InstPrinter.c:isSignedType_int64_t
Line
Count
Source
2414
317
  { \
2415
317
    return CHAR(T) == 'i'; \
2416
317
  }
AArch64InstPrinter.c:isSignedType_int32_t
Line
Count
Source
2414
134
  { \
2415
134
    return CHAR(T) == 'i'; \
2416
134
  }
AArch64InstPrinter.c:isSignedType_uint16_t
Line
Count
Source
2414
491
  { \
2415
491
    return CHAR(T) == 'i'; \
2416
491
  }
AArch64InstPrinter.c:isSignedType_uint8_t
Line
Count
Source
2414
70
  { \
2415
70
    return CHAR(T) == 'i'; \
2416
70
  }
AArch64InstPrinter.c:isSignedType_uint64_t
Line
Count
Source
2414
327
  { \
2415
327
    return CHAR(T) == 'i'; \
2416
327
  }
AArch64InstPrinter.c:isSignedType_uint32_t
Line
Count
Source
2414
551
  { \
2415
551
    return CHAR(T) == 'i'; \
2416
551
  }
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
2.88k
  { \
2430
2.88k
    AArch64_add_cs_detail_1( \
2431
2.88k
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
2.88k
    unsigned UnscaledVal = \
2433
2.88k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
2.88k
    unsigned Shift = \
2435
2.88k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
2.88k
\
2437
2.88k
    if ((UnscaledVal == 0) && \
2438
2.88k
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2439
289
      SStream_concat(O, "%s", markup("<imm:")); \
2440
289
      SStream_concat1(O, '#'); \
2441
289
      printUInt64(O, (UnscaledVal)); \
2442
289
      SStream_concat0(O, markup(">")); \
2443
289
      printShifter(MI, OpNum + 1, O); \
2444
289
      return; \
2445
289
    } \
2446
2.88k
\
2447
2.88k
    T Val; \
2448
2.59k
    if (CONCAT(isSignedType, T)()) \
2449
2.59k
      Val = (int8_t)UnscaledVal * \
2450
1.15k
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
2.59k
    else \
2452
2.59k
      Val = (uint8_t)UnscaledVal * \
2453
1.43k
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
2.59k
\
2455
2.59k
    CONCAT(printImmSVE, T)(Val, O); \
2456
2.59k
  }
printImm8OptLsl_int16_t
Line
Count
Source
2429
564
  { \
2430
564
    AArch64_add_cs_detail_1( \
2431
564
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
564
    unsigned UnscaledVal = \
2433
564
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
564
    unsigned Shift = \
2435
564
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
564
\
2437
564
    if ((UnscaledVal == 0) && \
2438
564
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2439
48
      SStream_concat(O, "%s", markup("<imm:")); \
2440
48
      SStream_concat1(O, '#'); \
2441
48
      printUInt64(O, (UnscaledVal)); \
2442
48
      SStream_concat0(O, markup(">")); \
2443
48
      printShifter(MI, OpNum + 1, O); \
2444
48
      return; \
2445
48
    } \
2446
564
\
2447
564
    T Val; \
2448
516
    if (CONCAT(isSignedType, T)()) \
2449
516
      Val = (int8_t)UnscaledVal * \
2450
516
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
516
    else \
2452
516
      Val = (uint8_t)UnscaledVal * \
2453
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
516
\
2455
516
    CONCAT(printImmSVE, T)(Val, O); \
2456
516
  }
printImm8OptLsl_int8_t
Line
Count
Source
2429
186
  { \
2430
186
    AArch64_add_cs_detail_1( \
2431
186
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
186
    unsigned UnscaledVal = \
2433
186
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
186
    unsigned Shift = \
2435
186
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
186
\
2437
186
    if ((UnscaledVal == 0) && \
2438
186
        (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
186
\
2447
186
    T Val; \
2448
186
    if (CONCAT(isSignedType, T)()) \
2449
186
      Val = (int8_t)UnscaledVal * \
2450
186
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
186
    else \
2452
186
      Val = (uint8_t)UnscaledVal * \
2453
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
186
\
2455
186
    CONCAT(printImmSVE, T)(Val, O); \
2456
186
  }
printImm8OptLsl_int64_t
Line
Count
Source
2429
332
  { \
2430
332
    AArch64_add_cs_detail_1( \
2431
332
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
332
    unsigned UnscaledVal = \
2433
332
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
332
    unsigned Shift = \
2435
332
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
332
\
2437
332
    if ((UnscaledVal == 0) && \
2438
332
        (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
332
\
2447
332
    T Val; \
2448
317
    if (CONCAT(isSignedType, T)()) \
2449
317
      Val = (int8_t)UnscaledVal * \
2450
317
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
317
    else \
2452
317
      Val = (uint8_t)UnscaledVal * \
2453
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
317
\
2455
317
    CONCAT(printImmSVE, T)(Val, O); \
2456
317
  }
printImm8OptLsl_int32_t
Line
Count
Source
2429
211
  { \
2430
211
    AArch64_add_cs_detail_1( \
2431
211
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
211
    unsigned UnscaledVal = \
2433
211
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
211
    unsigned Shift = \
2435
211
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
211
\
2437
211
    if ((UnscaledVal == 0) && \
2438
211
        (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
211
\
2447
211
    T Val; \
2448
134
    if (CONCAT(isSignedType, T)()) \
2449
134
      Val = (int8_t)UnscaledVal * \
2450
134
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
134
    else \
2452
134
      Val = (uint8_t)UnscaledVal * \
2453
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
134
\
2455
134
    CONCAT(printImmSVE, T)(Val, O); \
2456
134
  }
printImm8OptLsl_uint16_t
Line
Count
Source
2429
511
  { \
2430
511
    AArch64_add_cs_detail_1( \
2431
511
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
511
    unsigned UnscaledVal = \
2433
511
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
511
    unsigned Shift = \
2435
511
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
511
\
2437
511
    if ((UnscaledVal == 0) && \
2438
511
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2439
20
      SStream_concat(O, "%s", markup("<imm:")); \
2440
20
      SStream_concat1(O, '#'); \
2441
20
      printUInt64(O, (UnscaledVal)); \
2442
20
      SStream_concat0(O, markup(">")); \
2443
20
      printShifter(MI, OpNum + 1, O); \
2444
20
      return; \
2445
20
    } \
2446
511
\
2447
511
    T Val; \
2448
491
    if (CONCAT(isSignedType, T)()) \
2449
491
      Val = (int8_t)UnscaledVal * \
2450
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
491
    else \
2452
491
      Val = (uint8_t)UnscaledVal * \
2453
491
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
491
\
2455
491
    CONCAT(printImmSVE, T)(Val, O); \
2456
491
  }
printImm8OptLsl_uint8_t
Line
Count
Source
2429
70
  { \
2430
70
    AArch64_add_cs_detail_1( \
2431
70
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
70
    unsigned UnscaledVal = \
2433
70
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
70
    unsigned Shift = \
2435
70
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
70
\
2437
70
    if ((UnscaledVal == 0) && \
2438
70
        (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
70
\
2447
70
    T Val; \
2448
70
    if (CONCAT(isSignedType, T)()) \
2449
70
      Val = (int8_t)UnscaledVal * \
2450
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
70
    else \
2452
70
      Val = (uint8_t)UnscaledVal * \
2453
70
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
70
\
2455
70
    CONCAT(printImmSVE, T)(Val, O); \
2456
70
  }
printImm8OptLsl_uint64_t
Line
Count
Source
2429
385
  { \
2430
385
    AArch64_add_cs_detail_1( \
2431
385
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
385
    unsigned UnscaledVal = \
2433
385
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
385
    unsigned Shift = \
2435
385
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
385
\
2437
385
    if ((UnscaledVal == 0) && \
2438
385
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2439
58
      SStream_concat(O, "%s", markup("<imm:")); \
2440
58
      SStream_concat1(O, '#'); \
2441
58
      printUInt64(O, (UnscaledVal)); \
2442
58
      SStream_concat0(O, markup(">")); \
2443
58
      printShifter(MI, OpNum + 1, O); \
2444
58
      return; \
2445
58
    } \
2446
385
\
2447
385
    T Val; \
2448
327
    if (CONCAT(isSignedType, T)()) \
2449
327
      Val = (int8_t)UnscaledVal * \
2450
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
327
    else \
2452
327
      Val = (uint8_t)UnscaledVal * \
2453
327
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
327
\
2455
327
    CONCAT(printImmSVE, T)(Val, O); \
2456
327
  }
printImm8OptLsl_uint32_t
Line
Count
Source
2429
622
  { \
2430
622
    AArch64_add_cs_detail_1( \
2431
622
      MI, CONCAT(AArch64_OP_GROUP_Imm8OptLsl, T), OpNum, sizeof(T)); \
2432
622
    unsigned UnscaledVal = \
2433
622
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2434
622
    unsigned Shift = \
2435
622
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 1))); \
2436
622
\
2437
622
    if ((UnscaledVal == 0) && \
2438
622
        (AArch64_AM_getShiftValue(Shift) != 0)) { \
2439
71
      SStream_concat(O, "%s", markup("<imm:")); \
2440
71
      SStream_concat1(O, '#'); \
2441
71
      printUInt64(O, (UnscaledVal)); \
2442
71
      SStream_concat0(O, markup(">")); \
2443
71
      printShifter(MI, OpNum + 1, O); \
2444
71
      return; \
2445
71
    } \
2446
622
\
2447
622
    T Val; \
2448
551
    if (CONCAT(isSignedType, T)()) \
2449
551
      Val = (int8_t)UnscaledVal * \
2450
0
            (1 << AArch64_AM_getShiftValue(Shift)); \
2451
551
    else \
2452
551
      Val = (uint8_t)UnscaledVal * \
2453
551
            (1 << AArch64_AM_getShiftValue(Shift)); \
2454
551
\
2455
551
    CONCAT(printImmSVE, T)(Val, O); \
2456
551
  }
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
1.84k
  { \
2470
1.84k
    AArch64_add_cs_detail_1( \
2471
1.84k
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2472
1.84k
      sizeof(T)); \
2473
1.84k
    typedef T SignedT; \
2474
1.84k
    typedef CONCATS(u, T) UnsignedT; \
2475
1.84k
\
2476
1.84k
    uint64_t Val = \
2477
1.84k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2478
1.84k
    UnsignedT PrintVal = \
2479
1.84k
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2480
1.84k
\
2481
1.84k
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2482
1.84k
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2483
1.84k
    else if ((uint16_t)PrintVal == PrintVal) \
2484
1.29k
      CONCAT(printImmSVE, T)(PrintVal, O); \
2485
1.29k
    else { \
2486
1.14k
      SStream_concat(O, "%s", markup("<imm:")); \
2487
1.14k
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2488
1.14k
      SStream_concat0(O, markup(">")); \
2489
1.14k
    } \
2490
1.84k
  }
printSVELogicalImm_int16_t
Line
Count
Source
2469
244
  { \
2470
244
    AArch64_add_cs_detail_1( \
2471
244
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2472
244
      sizeof(T)); \
2473
244
    typedef T SignedT; \
2474
244
    typedef CONCATS(u, T) UnsignedT; \
2475
244
\
2476
244
    uint64_t Val = \
2477
244
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2478
244
    UnsignedT PrintVal = \
2479
244
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2480
244
\
2481
244
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2482
244
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2483
244
    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
244
  }
printSVELogicalImm_int32_t
Line
Count
Source
2469
913
  { \
2470
913
    AArch64_add_cs_detail_1( \
2471
913
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2472
913
      sizeof(T)); \
2473
913
    typedef T SignedT; \
2474
913
    typedef CONCATS(u, T) UnsignedT; \
2475
913
\
2476
913
    uint64_t Val = \
2477
913
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2478
913
    UnsignedT PrintVal = \
2479
913
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2480
913
\
2481
913
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2482
913
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2483
913
    else if ((uint16_t)PrintVal == PrintVal) \
2484
691
      CONCAT(printImmSVE, T)(PrintVal, O); \
2485
691
    else { \
2486
572
      SStream_concat(O, "%s", markup("<imm:")); \
2487
572
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2488
572
      SStream_concat0(O, markup(">")); \
2489
572
    } \
2490
913
  }
printSVELogicalImm_int64_t
Line
Count
Source
2469
689
  { \
2470
689
    AArch64_add_cs_detail_1( \
2471
689
      MI, CONCAT(AArch64_OP_GROUP_SVELogicalImm, T), OpNum, \
2472
689
      sizeof(T)); \
2473
689
    typedef T SignedT; \
2474
689
    typedef CONCATS(u, T) UnsignedT; \
2475
689
\
2476
689
    uint64_t Val = \
2477
689
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2478
689
    UnsignedT PrintVal = \
2479
689
      AArch64_AM_decodeLogicalImmediate(Val, 64); \
2480
689
\
2481
689
    if ((int16_t)PrintVal == (SignedT)PrintVal) \
2482
689
      CONCAT(printImmSVE, T)((T)PrintVal, O); \
2483
689
    else if ((uint16_t)PrintVal == PrintVal) \
2484
608
      CONCAT(printImmSVE, T)(PrintVal, O); \
2485
608
    else { \
2486
568
      SStream_concat(O, "%s", markup("<imm:")); \
2487
568
      printUInt64Bang(O, ((uint64_t)PrintVal)); \
2488
568
      SStream_concat0(O, markup(">")); \
2489
568
    } \
2490
689
  }
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.52k
  { \
2499
1.52k
    AArch64_add_cs_detail_1( \
2500
1.52k
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2501
1.52k
      Width); \
2502
1.52k
    unsigned Base; \
2503
1.52k
    switch (Width) { \
2504
36
    case 8: \
2505
36
      Base = AArch64_B0; \
2506
36
      break; \
2507
630
    case 16: \
2508
630
      Base = AArch64_H0; \
2509
630
      break; \
2510
176
    case 32: \
2511
176
      Base = AArch64_S0; \
2512
176
      break; \
2513
663
    case 64: \
2514
663
      Base = AArch64_D0; \
2515
663
      break; \
2516
20
    case 128: \
2517
20
      Base = AArch64_Q0; \
2518
20
      break; \
2519
0
    default: \
2520
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2521
1.52k
    } \
2522
1.52k
    unsigned Reg = \
2523
1.52k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2524
1.52k
    printRegName(O, Reg - AArch64_Z0 + Base); \
2525
1.52k
  }
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
663
  { \
2499
663
    AArch64_add_cs_detail_1( \
2500
663
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2501
663
      Width); \
2502
663
    unsigned Base; \
2503
663
    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
663
    case 64: \
2514
663
      Base = AArch64_D0; \
2515
663
      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
663
    } \
2522
663
    unsigned Reg = \
2523
663
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2524
663
    printRegName(O, Reg - AArch64_Z0 + Base); \
2525
663
  }
printZPRasFPR_16
Line
Count
Source
2498
630
  { \
2499
630
    AArch64_add_cs_detail_1( \
2500
630
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2501
630
      Width); \
2502
630
    unsigned Base; \
2503
630
    switch (Width) { \
2504
0
    case 8: \
2505
0
      Base = AArch64_B0; \
2506
0
      break; \
2507
630
    case 16: \
2508
630
      Base = AArch64_H0; \
2509
630
      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
630
    } \
2522
630
    unsigned Reg = \
2523
630
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2524
630
    printRegName(O, Reg - AArch64_Z0 + Base); \
2525
630
  }
printZPRasFPR_32
Line
Count
Source
2498
176
  { \
2499
176
    AArch64_add_cs_detail_1( \
2500
176
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2501
176
      Width); \
2502
176
    unsigned Base; \
2503
176
    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
176
    case 32: \
2511
176
      Base = AArch64_S0; \
2512
176
      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
176
    } \
2522
176
    unsigned Reg = \
2523
176
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2524
176
    printRegName(O, Reg - AArch64_Z0 + Base); \
2525
176
  }
printZPRasFPR_128
Line
Count
Source
2498
20
  { \
2499
20
    AArch64_add_cs_detail_1( \
2500
20
      MI, CONCAT(AArch64_OP_GROUP_ZPRasFPR, Width), OpNum, \
2501
20
      Width); \
2502
20
    unsigned Base; \
2503
20
    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
20
    case 128: \
2517
20
      Base = AArch64_Q0; \
2518
20
      break; \
2519
0
    default: \
2520
0
      CS_ASSERT_RET(0 && "Unsupported width"); \
2521
20
    } \
2522
20
    unsigned Reg = \
2523
20
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
2524
20
    printRegName(O, Reg - AArch64_Z0 + Base); \
2525
20
  }
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
1.64k
  { \
2536
1.64k
    AArch64_add_cs_detail_2( \
2537
1.64k
      MI, \
2538
1.64k
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2539
1.64k
             ImmIs1), \
2540
1.64k
      OpNum, ImmIs0, ImmIs1); \
2541
1.64k
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2542
1.64k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2543
1.64k
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2544
1.64k
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2545
1.64k
    unsigned Val = \
2546
1.64k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2547
1.64k
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2548
1.64k
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2549
1.64k
    SStream_concat0(O, markup(">")); \
2550
1.64k
  }
printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_one
Line
Count
Source
2535
68
  { \
2536
68
    AArch64_add_cs_detail_2( \
2537
68
      MI, \
2538
68
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2539
68
             ImmIs1), \
2540
68
      OpNum, ImmIs0, ImmIs1); \
2541
68
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2542
68
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2543
68
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2544
68
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2545
68
    unsigned Val = \
2546
68
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2547
68
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2548
68
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2549
68
    SStream_concat0(O, markup(">")); \
2550
68
  }
printExactFPImm_AArch64ExactFPImm_zero_AArch64ExactFPImm_one
Line
Count
Source
2535
693
  { \
2536
693
    AArch64_add_cs_detail_2( \
2537
693
      MI, \
2538
693
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2539
693
             ImmIs1), \
2540
693
      OpNum, ImmIs0, ImmIs1); \
2541
693
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2542
693
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2543
693
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2544
693
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2545
693
    unsigned Val = \
2546
693
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2547
693
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2548
693
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2549
693
    SStream_concat0(O, markup(">")); \
2550
693
  }
printExactFPImm_AArch64ExactFPImm_half_AArch64ExactFPImm_two
Line
Count
Source
2535
883
  { \
2536
883
    AArch64_add_cs_detail_2( \
2537
883
      MI, \
2538
883
      CONCAT(CONCAT(AArch64_OP_GROUP_ExactFPImm, ImmIs0), \
2539
883
             ImmIs1), \
2540
883
      OpNum, ImmIs0, ImmIs1); \
2541
883
    const AArch64ExactFPImm_ExactFPImm *Imm0Desc = \
2542
883
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs0); \
2543
883
    const AArch64ExactFPImm_ExactFPImm *Imm1Desc = \
2544
883
      AArch64ExactFPImm_lookupExactFPImmByEnum(ImmIs1); \
2545
883
    unsigned Val = \
2546
883
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
2547
883
    SStream_concat(O, "%s%s%s", markup("<imm:"), "#", \
2548
883
             (Val ? Imm1Desc->Repr : Imm0Desc->Repr)); \
2549
883
    SStream_concat0(O, markup(">")); \
2550
883
  }
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
4.16k
{
2557
4.16k
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64as32, OpNum);
2558
4.16k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2559
4.16k
  printRegName(O, getWRegFromXReg(Reg));
2560
4.16k
}
2561
2562
void printGPR64x8(MCInst *MI, unsigned OpNum, SStream *O)
2563
31
{
2564
31
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_GPR64x8, OpNum);
2565
31
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2566
31
  printRegName(O,
2567
31
         MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_x8sub_0));
2568
31
}
2569
2570
void printSyspXzrPair(MCInst *MI, unsigned OpNum, SStream *O)
2571
275
{
2572
275
  AArch64_add_cs_detail_0(MI, AArch64_OP_GROUP_SyspXzrPair, OpNum);
2573
275
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
2574
2575
275
  SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_NoRegAltName),
2576
275
           ", ");
2577
275
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2578
275
}
2579
2580
const char *AArch64_LLVM_getRegisterName(unsigned RegNo, unsigned AltIdx)
2581
141k
{
2582
141k
  return getRegisterName(RegNo, AltIdx);
2583
141k
}
2584
2585
void AArch64_LLVM_printInstruction(MCInst *MI, SStream *O,
2586
           void * /* MCRegisterInfo* */ info)
2587
231k
{
2588
231k
  printInst(MI, MI->address, "", O);
2589
231k
}