Coverage Report

Created: 2025-11-11 06:33

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