Coverage Report

Created: 2025-11-24 06:12

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