Coverage Report

Created: 2024-09-08 06:22

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