Coverage Report

Created: 2026-10-17 07:17

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