Coverage Report

Created: 2026-01-10 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonev5/arch/AArch64/AArch64InstPrinter.c
Line
Count
Source
1
//==-- AArch64InstPrinter.cpp - Convert AArch64 MCInst to assembly syntax --==//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This class prints an AArch64 MCInst to a .s file.
11
//
12
//===----------------------------------------------------------------------===//
13
14
/* Capstone Disassembly Engine */
15
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2016 */
16
17
#ifdef CAPSTONE_HAS_ARM64
18
19
#include <capstone/platform.h>
20
#include <stdio.h>
21
#include <stdlib.h>
22
23
#include "AArch64InstPrinter.h"
24
#include "AArch64Disassembler.h"
25
#include "AArch64BaseInfo.h"
26
#include "../../utils.h"
27
#include "../../MCInst.h"
28
#include "../../SStream.h"
29
#include "../../MCRegisterInfo.h"
30
#include "../../MathExtras.h"
31
32
#include "AArch64Mapping.h"
33
#include "AArch64AddressingModes.h"
34
35
#define GET_REGINFO_ENUM
36
#include "AArch64GenRegisterInfo.inc"
37
38
#define GET_INSTRINFO_ENUM
39
#include "AArch64GenInstrInfo.inc"
40
41
#include "AArch64GenSubtargetInfo.inc"
42
43
44
static const char *getRegisterName(unsigned RegNo, unsigned AltIdx);
45
static void printOperand(MCInst *MI, unsigned OpNum, SStream *O);
46
static bool printSysAlias(MCInst *MI, SStream *O);
47
static char *printAliasInstr(MCInst *MI, SStream *OS, MCRegisterInfo *MRI);
48
static void printInstruction(MCInst *MI, SStream *O);
49
static void printShifter(MCInst *MI, unsigned OpNum, SStream *O);
50
static void printCustomAliasOperand(MCInst *MI, uint64_t Address, unsigned OpIdx,
51
    unsigned PrintMethodIdx, SStream *OS);
52
53
54
static cs_ac_type get_op_access(cs_struct *h, unsigned int id, unsigned int index)
55
813k
{
56
813k
#ifndef CAPSTONE_DIET
57
813k
  const uint8_t *arr = AArch64_get_op_access(h, id);
58
59
813k
  if (arr[index] == CS_AC_IGNORE)
60
0
    return 0;
61
62
813k
  return arr[index];
63
#else
64
  return 0;
65
#endif
66
813k
}
67
68
static void op_addImm(MCInst *MI, int v)
69
2.62k
{
70
2.62k
  if (MI->csh->detail) {
71
2.62k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
72
2.62k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = v;
73
2.62k
    MI->flat_insn->detail->arm64.op_count++;
74
2.62k
  }
75
2.62k
}
76
77
static void set_sme_index(MCInst *MI, bool status)
78
10.0k
{
79
  // Doing SME Index operand
80
10.0k
  MI->csh->doing_SME_Index = status;
81
82
10.0k
  if (MI->csh->detail != CS_OPT_ON)
83
0
    return;
84
85
10.0k
  if (status) {
86
7.21k
    unsigned prevOpNum = MI->flat_insn->detail->arm64.op_count - 1; 
87
7.21k
    unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, prevOpNum));
88
    // Replace previous SME register operand with an OP_SME_INDEX operand
89
7.21k
    MI->flat_insn->detail->arm64.operands[prevOpNum].type = ARM64_OP_SME_INDEX;
90
7.21k
    MI->flat_insn->detail->arm64.operands[prevOpNum].sme_index.reg = Reg;
91
7.21k
    MI->flat_insn->detail->arm64.operands[prevOpNum].sme_index.base = ARM64_REG_INVALID;
92
7.21k
    MI->flat_insn->detail->arm64.operands[prevOpNum].sme_index.disp = 0;
93
7.21k
  }
94
10.0k
}
95
96
static void set_mem_access(MCInst *MI, bool status)
97
268k
{
98
  // If status == false, check if this is meant for SME_index
99
268k
  if(!status && MI->csh->doing_SME_Index) {
100
4.42k
    MI->csh->doing_SME_Index = status;
101
4.42k
    return;
102
4.42k
  }
103
104
  // Doing Memory Operation
105
263k
  MI->csh->doing_mem = status;
106
107
108
263k
  if (MI->csh->detail != CS_OPT_ON)
109
0
    return;
110
111
263k
  if (status) {
112
131k
#ifndef CAPSTONE_DIET
113
131k
    uint8_t access;
114
131k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
115
131k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
116
131k
    MI->ac_idx++;
117
131k
#endif
118
131k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_MEM;
119
131k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.base = ARM64_REG_INVALID;
120
131k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.index = ARM64_REG_INVALID;
121
131k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = 0;
122
131k
  } else {
123
    // done, create the next operand slot
124
131k
    MI->flat_insn->detail->arm64.op_count++;
125
131k
  }
126
263k
}
127
128
void AArch64_printInst(MCInst *MI, SStream *O, void *Info)
129
285k
{
130
  // Check for special encodings and print the canonical alias instead.
131
285k
  unsigned Opcode = MCInst_getOpcode(MI);
132
285k
  int LSB, Width;
133
285k
  char *mnem;
134
135
  // printf(">>> opcode = %u\n", MCInst_getOpcode(MI));
136
137
285k
  if (Opcode == AArch64_SYSxt && printSysAlias(MI, O))
138
742
    return;
139
140
  // SBFM/UBFM should print to a nicer aliased form if possible.
141
284k
  if (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri ||
142
283k
      Opcode == AArch64_UBFMXri || Opcode == AArch64_UBFMWri) {
143
2.35k
    bool IsSigned = (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri);
144
2.35k
    bool Is64Bit = (Opcode == AArch64_SBFMXri || Opcode == AArch64_UBFMXri);
145
146
2.35k
    MCOperand *Op0 = MCInst_getOperand(MI, 0);
147
2.35k
    MCOperand *Op1 = MCInst_getOperand(MI, 1);
148
2.35k
    MCOperand *Op2 = MCInst_getOperand(MI, 2);
149
2.35k
    MCOperand *Op3 = MCInst_getOperand(MI, 3);
150
151
2.35k
    if (MCOperand_isImm(Op2) && MCOperand_getImm(Op2) == 0 && MCOperand_isImm(Op3)) {
152
1.87k
      const char *AsmMnemonic = NULL;
153
154
1.87k
      switch (MCOperand_getImm(Op3)) {
155
209
        default:
156
209
          break;
157
158
794
        case 7:
159
794
          if (IsSigned)
160
569
            AsmMnemonic = "sxtb";
161
225
          else if (!Is64Bit)
162
157
            AsmMnemonic = "uxtb";
163
794
          break;
164
165
563
        case 15:
166
563
          if (IsSigned)
167
389
            AsmMnemonic = "sxth";
168
174
          else if (!Is64Bit)
169
138
            AsmMnemonic = "uxth";
170
563
          break;
171
172
308
        case 31:
173
          // *xtw is only valid for signed 64-bit operations.
174
308
          if (Is64Bit && IsSigned)
175
149
            AsmMnemonic = "sxtw";
176
308
          break;
177
1.87k
      }
178
179
1.87k
      if (AsmMnemonic) {
180
1.40k
        SStream_concat(O, "%s\t%s, %s", AsmMnemonic,
181
1.40k
            getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
182
1.40k
            getRegisterName(getWRegFromXReg(MCOperand_getReg(Op1)), AArch64_NoRegAltName));
183
184
1.40k
        if (MI->csh->detail) {
185
1.40k
#ifndef CAPSTONE_DIET
186
1.40k
          uint8_t access;
187
1.40k
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
188
1.40k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
189
1.40k
          MI->ac_idx++;
190
1.40k
#endif
191
1.40k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
192
1.40k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
193
1.40k
          MI->flat_insn->detail->arm64.op_count++;
194
1.40k
#ifndef CAPSTONE_DIET
195
1.40k
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
196
1.40k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
197
1.40k
          MI->ac_idx++;
198
1.40k
#endif
199
1.40k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
200
1.40k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = getWRegFromXReg(MCOperand_getReg(Op1));
201
1.40k
          MI->flat_insn->detail->arm64.op_count++;
202
1.40k
        }
203
204
1.40k
        MCInst_setOpcodePub(MI, AArch64_map_insn(AsmMnemonic));
205
206
1.40k
        return;
207
1.40k
      }
208
1.87k
    }
209
210
    // All immediate shifts are aliases, implemented using the Bitfield
211
    // instruction. In all cases the immediate shift amount shift must be in
212
    // the range 0 to (reg.size -1).
213
950
    if (MCOperand_isImm(Op2) && MCOperand_isImm(Op3)) {
214
950
      const char *AsmMnemonic = NULL;
215
950
      int shift = 0;
216
950
      int immr = (int)MCOperand_getImm(Op2);
217
950
      int imms = (int)MCOperand_getImm(Op3);
218
219
950
      if (Opcode == AArch64_UBFMWri && imms != 0x1F && ((imms + 1) == immr)) {
220
75
        AsmMnemonic = "lsl";
221
75
        shift = 31 - imms;
222
875
      } else if (Opcode == AArch64_UBFMXri && imms != 0x3f &&
223
208
          ((imms + 1 == immr))) {
224
6
        AsmMnemonic = "lsl";
225
6
        shift = 63 - imms;
226
869
      } else if (Opcode == AArch64_UBFMWri && imms == 0x1f) {
227
96
        AsmMnemonic = "lsr";
228
96
        shift = immr;
229
773
      } else if (Opcode == AArch64_UBFMXri && imms == 0x3f) {
230
66
        AsmMnemonic = "lsr";
231
66
        shift = immr;
232
707
      } else if (Opcode == AArch64_SBFMWri && imms == 0x1f) {
233
9
        AsmMnemonic = "asr";
234
9
        shift = immr;
235
698
      } else if (Opcode == AArch64_SBFMXri && imms == 0x3f) {
236
99
        AsmMnemonic = "asr";
237
99
        shift = immr;
238
99
      }
239
240
950
      if (AsmMnemonic) {
241
351
        SStream_concat(O, "%s\t%s, %s, ", AsmMnemonic,
242
351
            getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
243
351
            getRegisterName(MCOperand_getReg(Op1), AArch64_NoRegAltName));
244
245
351
        printInt32Bang(O, shift);
246
247
351
        MCInst_setOpcodePub(MI, AArch64_map_insn(AsmMnemonic));
248
249
351
        if (MI->csh->detail) {
250
351
#ifndef CAPSTONE_DIET
251
351
          uint8_t access;
252
351
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
253
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
254
351
          MI->ac_idx++;
255
351
#endif
256
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
257
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
258
351
          MI->flat_insn->detail->arm64.op_count++;
259
351
#ifndef CAPSTONE_DIET
260
351
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
261
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
262
351
          MI->ac_idx++;
263
351
#endif
264
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
265
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op1);
266
351
          MI->flat_insn->detail->arm64.op_count++;
267
351
#ifndef CAPSTONE_DIET
268
351
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
269
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
270
351
          MI->ac_idx++;
271
351
#endif
272
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
273
351
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = shift;
274
351
          MI->flat_insn->detail->arm64.op_count++;
275
351
        }
276
277
351
        return;
278
351
      }
279
950
    }
280
281
    // SBFIZ/UBFIZ aliases
282
599
    if (MCOperand_getImm(Op2) > MCOperand_getImm(Op3)) {
283
225
      SStream_concat(O, "%s\t%s, %s, ", (IsSigned ? "sbfiz" : "ubfiz"),
284
225
          getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
285
225
          getRegisterName(MCOperand_getReg(Op1), AArch64_NoRegAltName));
286
287
225
      printInt32Bang(O, (int)((Is64Bit ? 64 : 32) - MCOperand_getImm(Op2)));
288
289
225
      SStream_concat0(O, ", ");
290
291
225
      printInt32Bang(O, (int)MCOperand_getImm(Op3) + 1);
292
293
225
      MCInst_setOpcodePub(MI, AArch64_map_insn(IsSigned ? "sbfiz" : "ubfiz"));
294
295
225
      if (MI->csh->detail) {
296
225
#ifndef CAPSTONE_DIET
297
225
        uint8_t access;
298
225
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
299
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
300
225
        MI->ac_idx++;
301
225
#endif
302
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
303
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
304
225
        MI->flat_insn->detail->arm64.op_count++;
305
225
#ifndef CAPSTONE_DIET
306
225
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
307
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
308
225
        MI->ac_idx++;
309
225
#endif
310
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
311
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op1);
312
225
        MI->flat_insn->detail->arm64.op_count++;
313
225
#ifndef CAPSTONE_DIET
314
225
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
315
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
316
225
        MI->ac_idx++;
317
225
#endif
318
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
319
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = (Is64Bit ? 64 : 32) - (int)MCOperand_getImm(Op2);
320
225
        MI->flat_insn->detail->arm64.op_count++;
321
225
#ifndef CAPSTONE_DIET
322
225
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
323
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
324
225
        MI->ac_idx++;
325
225
#endif
326
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
327
225
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op3) + 1;
328
225
        MI->flat_insn->detail->arm64.op_count++;
329
225
      }
330
331
225
      return;
332
225
    }
333
334
    // Otherwise SBFX/UBFX is the preferred form
335
374
    SStream_concat(O, "%s\t%s, %s, ", (IsSigned ? "sbfx" : "ubfx"),
336
374
        getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
337
374
        getRegisterName(MCOperand_getReg(Op1), AArch64_NoRegAltName));
338
339
374
    printInt32Bang(O, (int)MCOperand_getImm(Op2));
340
374
    SStream_concat0(O, ", ");
341
374
    printInt32Bang(O, (int)MCOperand_getImm(Op3) - (int)MCOperand_getImm(Op2) + 1);
342
343
374
    MCInst_setOpcodePub(MI, AArch64_map_insn(IsSigned ? "sbfx" : "ubfx"));
344
345
374
    if (MI->csh->detail) {
346
374
#ifndef CAPSTONE_DIET
347
374
      uint8_t access;
348
374
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
349
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
350
374
      MI->ac_idx++;
351
374
#endif
352
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
353
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
354
374
      MI->flat_insn->detail->arm64.op_count++;
355
374
#ifndef CAPSTONE_DIET
356
374
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
357
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
358
374
      MI->ac_idx++;
359
374
#endif
360
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
361
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op1);
362
374
      MI->flat_insn->detail->arm64.op_count++;
363
374
#ifndef CAPSTONE_DIET
364
374
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
365
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
366
374
      MI->ac_idx++;
367
374
#endif
368
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
369
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op2);
370
374
      MI->flat_insn->detail->arm64.op_count++;
371
374
#ifndef CAPSTONE_DIET
372
374
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
373
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
374
374
      MI->ac_idx++;
375
374
#endif
376
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
377
374
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op3) - MCOperand_getImm(Op2) + 1;
378
374
      MI->flat_insn->detail->arm64.op_count++;
379
374
    }
380
381
374
    return;
382
599
  }
383
384
282k
  if (Opcode == AArch64_BFMXri || Opcode == AArch64_BFMWri) {
385
555
    MCOperand *Op0 = MCInst_getOperand(MI, 0); // Op1 == Op0
386
555
    MCOperand *Op2 = MCInst_getOperand(MI, 2);
387
555
    int ImmR = (int)MCOperand_getImm(MCInst_getOperand(MI, 3));
388
555
    int ImmS = (int)MCOperand_getImm(MCInst_getOperand(MI, 4));
389
390
555
    if ((MCOperand_getReg(Op2) == AArch64_WZR || MCOperand_getReg(Op2) == AArch64_XZR) &&
391
176
        (ImmR == 0 || ImmS < ImmR)) {
392
      // BFC takes precedence over its entire range, sligtly differently to BFI.
393
149
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
394
149
      int LSB = (BitWidth - ImmR) % BitWidth;
395
149
      int Width = ImmS + 1;
396
397
149
      SStream_concat(O, "bfc\t%s, ",
398
149
          getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName));
399
400
149
      printInt32Bang(O, LSB);
401
149
      SStream_concat0(O, ", ");
402
149
      printInt32Bang(O, Width);
403
149
      MCInst_setOpcodePub(MI, AArch64_map_insn("bfc"));
404
405
149
      if (MI->csh->detail) {
406
149
#ifndef CAPSTONE_DIET
407
149
        uint8_t access;
408
149
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
409
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
410
149
        MI->ac_idx++;
411
149
#endif
412
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
413
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
414
149
        MI->flat_insn->detail->arm64.op_count++;
415
416
149
#ifndef CAPSTONE_DIET
417
149
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
418
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
419
149
        MI->ac_idx++;
420
149
#endif
421
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
422
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = LSB;
423
149
        MI->flat_insn->detail->arm64.op_count++;
424
149
#ifndef CAPSTONE_DIET
425
149
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
426
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
427
149
        MI->ac_idx++;
428
149
#endif
429
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
430
149
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Width;
431
149
        MI->flat_insn->detail->arm64.op_count++;
432
149
      }
433
434
149
      return;
435
406
    } else if (ImmS < ImmR) {
436
      // BFI alias
437
153
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
438
153
      LSB = (BitWidth - ImmR) % BitWidth;
439
153
      Width = ImmS + 1;
440
441
153
      SStream_concat(O, "bfi\t%s, %s, ",
442
153
          getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
443
153
          getRegisterName(MCOperand_getReg(Op2), AArch64_NoRegAltName));
444
445
153
      printInt32Bang(O, LSB);
446
153
      SStream_concat0(O, ", ");
447
153
      printInt32Bang(O, Width);
448
449
153
      MCInst_setOpcodePub(MI, AArch64_map_insn("bfi"));
450
451
153
      if (MI->csh->detail) {
452
153
#ifndef CAPSTONE_DIET
453
153
        uint8_t access;
454
153
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
455
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
456
153
        MI->ac_idx++;
457
153
#endif
458
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
459
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
460
153
        MI->flat_insn->detail->arm64.op_count++;
461
153
#ifndef CAPSTONE_DIET
462
153
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
463
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
464
153
        MI->ac_idx++;
465
153
#endif
466
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
467
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op2);
468
153
        MI->flat_insn->detail->arm64.op_count++;
469
153
#ifndef CAPSTONE_DIET
470
153
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
471
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
472
153
        MI->ac_idx++;
473
153
#endif
474
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
475
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = LSB;
476
153
        MI->flat_insn->detail->arm64.op_count++;
477
153
#ifndef CAPSTONE_DIET
478
153
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
479
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
480
153
        MI->ac_idx++;
481
153
#endif
482
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
483
153
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Width;
484
153
        MI->flat_insn->detail->arm64.op_count++;
485
153
      }
486
487
153
      return;
488
153
    }
489
490
253
    LSB = ImmR;
491
253
    Width = ImmS - ImmR + 1;
492
    // Otherwise BFXIL the preferred form
493
253
    SStream_concat(O, "bfxil\t%s, %s, ",
494
253
        getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
495
253
        getRegisterName(MCOperand_getReg(Op2), AArch64_NoRegAltName));
496
497
253
    printInt32Bang(O, LSB);
498
253
    SStream_concat0(O, ", ");
499
253
    printInt32Bang(O, Width);
500
501
253
    MCInst_setOpcodePub(MI, AArch64_map_insn("bfxil"));
502
503
253
    if (MI->csh->detail) {
504
253
#ifndef CAPSTONE_DIET
505
253
      uint8_t access;
506
253
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
507
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
508
253
      MI->ac_idx++;
509
253
#endif
510
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
511
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
512
253
      MI->flat_insn->detail->arm64.op_count++;
513
253
#ifndef CAPSTONE_DIET
514
253
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
515
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
516
253
      MI->ac_idx++;
517
253
#endif
518
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
519
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op2);
520
253
      MI->flat_insn->detail->arm64.op_count++;
521
253
#ifndef CAPSTONE_DIET
522
253
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
523
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
524
253
      MI->ac_idx++;
525
253
#endif
526
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
527
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = LSB;
528
253
      MI->flat_insn->detail->arm64.op_count++;
529
253
#ifndef CAPSTONE_DIET
530
253
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
531
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
532
253
      MI->ac_idx++;
533
253
#endif
534
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
535
253
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Width;
536
253
      MI->flat_insn->detail->arm64.op_count++;
537
253
    }
538
539
253
    return;
540
555
  }
541
542
  // MOVZ, MOVN and "ORR wzr, #imm" instructions are aliases for MOV, but their
543
  // domains overlap so they need to be prioritized. The chain is "MOVZ lsl #0 >
544
  // MOVZ lsl #N > MOVN lsl #0 > MOVN lsl #N > ORR". The highest instruction
545
  // that can represent the move is the MOV alias, and the rest get printed
546
  // normally.
547
281k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi) &&
548
692
      MCOperand_isImm(MCInst_getOperand(MI, 1)) && MCOperand_isImm(MCInst_getOperand(MI, 2))) {
549
692
    int RegWidth = Opcode == AArch64_MOVZXi ? 64 : 32;
550
692
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, 2));
551
692
    uint64_t Value = (uint64_t)MCOperand_getImm(MCInst_getOperand(MI, 1)) << Shift;
552
553
692
    if (isMOVZMovAlias(Value, Shift,
554
692
          Opcode == AArch64_MOVZXi ? 64 : 32)) {
555
606
      SStream_concat(O, "mov\t%s, ", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 0)), AArch64_NoRegAltName));
556
557
606
      printInt64Bang(O, SignExtend64(Value, RegWidth));
558
559
606
      if (MI->csh->detail) {
560
606
#ifndef CAPSTONE_DIET
561
606
        uint8_t access;
562
606
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
563
606
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
564
606
        MI->ac_idx++;
565
606
#endif
566
606
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
567
606
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0));
568
606
        MI->flat_insn->detail->arm64.op_count++;
569
570
606
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
571
606
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = SignExtend64(Value, RegWidth);
572
606
        MI->flat_insn->detail->arm64.op_count++;
573
606
      }
574
575
606
      MCInst_setOpcodePub(MI, AArch64_map_insn("mov"));
576
577
606
      return;
578
606
    }
579
692
  }
580
581
281k
  if ((Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
582
2.23k
      MCOperand_isImm(MCInst_getOperand(MI, 1)) && MCOperand_isImm(MCInst_getOperand(MI, 2))) {
583
2.23k
    int RegWidth = Opcode == AArch64_MOVNXi ? 64 : 32;
584
2.23k
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, 2));
585
2.23k
    uint64_t Value = ~((uint64_t)MCOperand_getImm(MCInst_getOperand(MI, 1)) << Shift);
586
587
2.23k
    if (RegWidth == 32)
588
959
      Value = Value & 0xffffffff;
589
590
2.23k
    if (AArch64_AM_isMOVNMovAlias(Value, Shift, RegWidth)) {
591
1.72k
      SStream_concat(O, "mov\t%s, ", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 0)), AArch64_NoRegAltName));
592
593
1.72k
      printInt64Bang(O, SignExtend64(Value, RegWidth));
594
595
1.72k
      if (MI->csh->detail) {
596
1.72k
#ifndef CAPSTONE_DIET
597
1.72k
        uint8_t access;
598
1.72k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
599
1.72k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
600
1.72k
        MI->ac_idx++;
601
1.72k
#endif
602
1.72k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
603
1.72k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0));
604
1.72k
        MI->flat_insn->detail->arm64.op_count++;
605
606
1.72k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
607
1.72k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = SignExtend64(Value, RegWidth);
608
1.72k
        MI->flat_insn->detail->arm64.op_count++;
609
1.72k
      }
610
611
1.72k
      MCInst_setOpcodePub(MI, AArch64_map_insn("mov"));
612
613
1.72k
      return;
614
1.72k
    }
615
2.23k
  }
616
617
279k
  if ((Opcode == AArch64_ORRXri || Opcode == AArch64_ORRWri) &&
618
951
      (MCOperand_getReg(MCInst_getOperand(MI, 1)) == AArch64_XZR ||
619
746
       MCOperand_getReg(MCInst_getOperand(MI, 1)) == AArch64_WZR) &&
620
396
      MCOperand_isImm(MCInst_getOperand(MI, 2))) {
621
396
    int RegWidth = Opcode == AArch64_ORRXri ? 64 : 32;
622
396
    uint64_t Value = AArch64_AM_decodeLogicalImmediate(
623
396
        MCOperand_getImm(MCInst_getOperand(MI, 2)), RegWidth);
624
396
    SStream_concat(O, "mov\t%s, ", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 0)), AArch64_NoRegAltName));
625
626
396
    printInt64Bang(O, SignExtend64(Value, RegWidth));
627
628
396
    if (MI->csh->detail) {
629
396
#ifndef CAPSTONE_DIET
630
396
      uint8_t access;
631
396
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
632
396
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
633
396
      MI->ac_idx++;
634
396
#endif
635
396
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
636
396
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0));
637
396
      MI->flat_insn->detail->arm64.op_count++;
638
639
396
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
640
396
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = SignExtend64(Value, RegWidth);
641
396
      MI->flat_insn->detail->arm64.op_count++;
642
396
    }
643
644
396
    MCInst_setOpcodePub(MI, AArch64_map_insn("mov"));
645
646
396
    return;
647
396
  }
648
649
  // Instruction TSB is specified as a one operand instruction, but 'csync' is
650
  // not encoded, so for printing it is treated as a special case here:
651
278k
  if (Opcode == AArch64_TSB) {
652
169
    SStream_concat0(O, "tsb\tcsync");
653
169
    MCInst_setOpcodePub(MI, AArch64_map_insn("tsb"));
654
169
    return;
655
169
  }
656
657
278k
  MI->MRI = Info;
658
659
278k
  mnem = printAliasInstr(MI, O, (MCRegisterInfo *)Info);
660
278k
  if (mnem) {
661
40.0k
    MCInst_setOpcodePub(MI, AArch64_map_insn(mnem));
662
40.0k
    cs_mem_free(mnem);
663
664
40.0k
    switch(MCInst_getOpcode(MI)) {
665
23.4k
      default: break;
666
23.4k
      case AArch64_LD1i8_POST:
667
234
        arm64_op_addImm(MI, 1);
668
234
        break;
669
284
      case AArch64_LD1i16_POST:
670
284
        arm64_op_addImm(MI, 2);
671
284
        break;
672
335
      case AArch64_LD1i32_POST:
673
335
        arm64_op_addImm(MI, 4);
674
335
        break;
675
85
      case AArch64_LD1Onev1d_POST:
676
318
      case AArch64_LD1Onev2s_POST:
677
407
      case AArch64_LD1Onev4h_POST:
678
671
      case AArch64_LD1Onev8b_POST:
679
1.58k
      case AArch64_LD1i64_POST:
680
1.58k
        arm64_op_addImm(MI, 8);
681
1.58k
        break;
682
50
      case AArch64_LD1Onev16b_POST:
683
108
      case AArch64_LD1Onev2d_POST:
684
208
      case AArch64_LD1Onev4s_POST:
685
233
      case AArch64_LD1Onev8h_POST:
686
260
      case AArch64_LD1Twov1d_POST:
687
315
      case AArch64_LD1Twov2s_POST:
688
356
      case AArch64_LD1Twov4h_POST:
689
828
      case AArch64_LD1Twov8b_POST:
690
828
        arm64_op_addImm(MI, 16);
691
828
        break;
692
80
      case AArch64_LD1Threev1d_POST:
693
142
      case AArch64_LD1Threev2s_POST:
694
233
      case AArch64_LD1Threev4h_POST:
695
253
      case AArch64_LD1Threev8b_POST:
696
253
        arm64_op_addImm(MI, 24);
697
253
        break;
698
538
      case AArch64_LD1Fourv1d_POST:
699
613
      case AArch64_LD1Fourv2s_POST:
700
1.03k
      case AArch64_LD1Fourv4h_POST:
701
1.14k
      case AArch64_LD1Fourv8b_POST:
702
1.28k
      case AArch64_LD1Twov16b_POST:
703
1.47k
      case AArch64_LD1Twov2d_POST:
704
1.65k
      case AArch64_LD1Twov4s_POST:
705
1.91k
      case AArch64_LD1Twov8h_POST:
706
1.91k
        arm64_op_addImm(MI, 32);
707
1.91k
        break;
708
352
      case AArch64_LD1Threev16b_POST:
709
376
      case AArch64_LD1Threev2d_POST:
710
503
      case AArch64_LD1Threev4s_POST:
711
658
      case AArch64_LD1Threev8h_POST:
712
658
         arm64_op_addImm(MI, 48);
713
658
         break;
714
112
      case AArch64_LD1Fourv16b_POST:
715
269
      case AArch64_LD1Fourv2d_POST:
716
625
      case AArch64_LD1Fourv4s_POST:
717
764
      case AArch64_LD1Fourv8h_POST:
718
764
        arm64_op_addImm(MI, 64);
719
764
        break;
720
76
      case AArch64_UMOVvi64:
721
76
        arm64_op_addVectorArrSpecifier(MI, ARM64_VAS_1D);
722
76
        break;
723
14
      case AArch64_UMOVvi32:
724
14
        arm64_op_addVectorArrSpecifier(MI, ARM64_VAS_1S);
725
14
        break;
726
68
      case AArch64_INSvi8gpr:
727
164
      case AArch64_DUP_ZI_B:
728
248
      case AArch64_CPY_ZPmI_B:
729
326
      case AArch64_CPY_ZPzI_B:
730
400
      case AArch64_CPY_ZPmV_B:
731
476
      case AArch64_CPY_ZPmR_B:
732
511
      case AArch64_DUP_ZR_B:
733
511
        if (MI->csh->detail) {
734
511
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
735
511
        }
736
511
        break;
737
7
      case AArch64_INSvi16gpr:
738
78
      case AArch64_DUP_ZI_H:
739
227
      case AArch64_CPY_ZPmI_H:
740
350
      case AArch64_CPY_ZPzI_H:
741
441
      case AArch64_CPY_ZPmV_H:
742
474
      case AArch64_CPY_ZPmR_H:
743
836
      case AArch64_DUP_ZR_H:
744
1.05k
      case AArch64_FCPY_ZPmI_H:
745
1.30k
      case AArch64_FDUP_ZI_H:
746
1.30k
        if (MI->csh->detail) {
747
1.30k
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
748
1.30k
        }
749
1.30k
        break;
750
42
      case AArch64_INSvi32gpr:
751
108
      case AArch64_DUP_ZI_S:
752
178
      case AArch64_CPY_ZPmI_S:
753
219
      case AArch64_CPY_ZPzI_S:
754
490
      case AArch64_CPY_ZPmV_S:
755
868
      case AArch64_CPY_ZPmR_S:
756
1.08k
      case AArch64_DUP_ZR_S:
757
1.16k
      case AArch64_FCPY_ZPmI_S:
758
1.21k
      case AArch64_FDUP_ZI_S:
759
1.21k
        if (MI->csh->detail) {
760
1.21k
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
761
1.21k
        }
762
1.21k
        break;
763
189
      case AArch64_INSvi64gpr:
764
906
      case AArch64_DUP_ZI_D:
765
938
      case AArch64_CPY_ZPmI_D:
766
968
      case AArch64_CPY_ZPzI_D:
767
1.16k
      case AArch64_CPY_ZPmV_D:
768
1.26k
      case AArch64_CPY_ZPmR_D:
769
1.63k
      case AArch64_DUP_ZR_D:
770
2.07k
      case AArch64_FCPY_ZPmI_D:
771
2.20k
      case AArch64_FDUP_ZI_D:
772
2.20k
        if (MI->csh->detail) {
773
2.20k
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
774
2.20k
        }
775
2.20k
        break;
776
290
      case AArch64_INSvi8lane:
777
320
      case AArch64_ORR_PPzPP:
778
403
      case AArch64_ORRS_PPzPP:
779
403
        if (MI->csh->detail) {
780
403
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
781
403
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1B;
782
403
        }
783
403
        break;
784
244
      case AArch64_INSvi16lane:
785
244
        if (MI->csh->detail) {
786
244
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
787
244
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1H;
788
244
        }
789
244
         break;
790
134
      case AArch64_INSvi32lane:
791
134
        if (MI->csh->detail) {
792
134
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
793
134
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1S;
794
134
        }
795
134
        break;
796
114
      case AArch64_INSvi64lane:
797
124
      case AArch64_ORR_ZZZ:
798
124
        if (MI->csh->detail) {
799
124
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
800
124
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1D;
801
124
        }
802
124
        break;
803
745
      case AArch64_ORRv16i8:
804
920
      case AArch64_NOTv16i8:
805
920
        if (MI->csh->detail) {
806
920
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_16B;
807
920
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_16B;
808
920
        }
809
920
        break;
810
597
      case AArch64_ORRv8i8:
811
632
      case AArch64_NOTv8i8:
812
632
        if (MI->csh->detail) {
813
632
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_8B;
814
632
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_8B;
815
632
        }
816
632
        break;
817
32
      case AArch64_AND_PPzPP:
818
42
      case AArch64_ANDS_PPzPP:
819
110
      case AArch64_EOR_PPzPP:
820
156
      case AArch64_EORS_PPzPP:
821
241
      case AArch64_SEL_PPPP:
822
322
      case AArch64_SEL_ZPZZ_B:
823
322
        if (MI->csh->detail) {
824
322
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
825
322
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1B;
826
322
        }
827
322
        break;
828
92
      case AArch64_SEL_ZPZZ_D:
829
92
        if (MI->csh->detail) {
830
92
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
831
92
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1D;
832
92
        }
833
92
        break;
834
359
      case AArch64_SEL_ZPZZ_H:
835
359
        if (MI->csh->detail) {
836
359
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
837
359
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1H;
838
359
        }
839
359
        break;
840
30
      case AArch64_SEL_ZPZZ_S:
841
30
        if (MI->csh->detail) {
842
30
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
843
30
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1S;
844
30
        }
845
30
        break;
846
232
      case AArch64_DUP_ZZI_B:
847
232
        if (MI->csh->detail) {
848
232
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
849
232
          if (MI->flat_insn->detail->arm64.op_count == 1) {
850
0
            arm64_op_addReg(MI, ARM64_REG_B0 + MCOperand_getReg(MCInst_getOperand(MI, 1)) - ARM64_REG_Z0);
851
232
          } else {
852
232
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1B;
853
232
          }
854
232
        }
855
232
        break;
856
81
      case AArch64_DUP_ZZI_D:
857
81
        if (MI->csh->detail) {
858
81
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
859
81
          if (MI->flat_insn->detail->arm64.op_count == 1) {
860
0
            arm64_op_addReg(MI, ARM64_REG_D0 + MCOperand_getReg(MCInst_getOperand(MI, 1)) - ARM64_REG_Z0);
861
81
          } else {
862
81
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1D;
863
81
          }
864
81
        }
865
81
        break;
866
297
      case AArch64_DUP_ZZI_H:
867
297
        if (MI->csh->detail) {
868
297
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
869
297
          if (MI->flat_insn->detail->arm64.op_count == 1) {
870
0
            arm64_op_addReg(MI, ARM64_REG_H0 + MCOperand_getReg(MCInst_getOperand(MI, 1)) - ARM64_REG_Z0);
871
297
          } else {
872
297
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1H;
873
297
          }
874
297
        }
875
297
        break;
876
72
      case AArch64_DUP_ZZI_Q:
877
72
        if (MI->csh->detail) {
878
72
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1Q;
879
72
          if (MI->flat_insn->detail->arm64.op_count == 1) {
880
0
            arm64_op_addReg(MI, ARM64_REG_Q0 + MCOperand_getReg(MCInst_getOperand(MI, 1)) - ARM64_REG_Z0);
881
72
          } else {
882
72
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1Q;
883
72
          }
884
72
         }
885
72
         break;
886
268
      case AArch64_DUP_ZZI_S:
887
268
        if (MI->csh->detail) {
888
268
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
889
268
          if (MI->flat_insn->detail->arm64.op_count == 1) {
890
0
            arm64_op_addReg(MI, ARM64_REG_S0 + MCOperand_getReg(MCInst_getOperand(MI, 1)) - ARM64_REG_Z0);
891
268
          } else {
892
268
             MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1S;
893
268
          }
894
268
        }
895
268
        break;
896
      // Hacky detail filling of SMSTART and SMSTOP alias'
897
226
      case AArch64_MSRpstatesvcrImm1:{
898
226
        if(MI->csh->detail){
899
226
          MI->flat_insn->detail->arm64.op_count = 2;
900
226
#ifndef CAPSTONE_DIET
901
226
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
902
226
          MI->ac_idx++;
903
226
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
904
226
          MI->ac_idx++;
905
226
#endif
906
226
          MI->flat_insn->detail->arm64.operands[0].type = ARM64_OP_SVCR;
907
226
          MI->flat_insn->detail->arm64.operands[0].sys = (unsigned)ARM64_SYSREG_SVCR;
908
226
          MI->flat_insn->detail->arm64.operands[0].svcr = lookupSVCRByEncoding(MCOperand_getImm(MCInst_getOperand(MI, 0)))->Encoding;
909
226
          MI->flat_insn->detail->arm64.operands[1].type = ARM64_OP_IMM;
910
226
          MI->flat_insn->detail->arm64.operands[1].imm = MCOperand_getImm(MCInst_getOperand(MI, 1));
911
226
        }
912
226
        break;
913
241
      }
914
40.0k
    }
915
238k
  } else {
916
238k
    printInstruction(MI, O);
917
238k
  }
918
278k
}
919
920
static bool printSysAlias(MCInst *MI, SStream *O)
921
3.01k
{
922
  // unsigned Opcode = MCInst_getOpcode(MI);
923
  //assert(Opcode == AArch64_SYSxt && "Invalid opcode for SYS alias!");
924
925
3.01k
  const char *Ins;
926
3.01k
  uint16_t Encoding;
927
3.01k
  bool NeedsReg;
928
3.01k
  char Name[64];
929
3.01k
  MCOperand *Op1 = MCInst_getOperand(MI, 0);
930
3.01k
  MCOperand *Cn = MCInst_getOperand(MI, 1);
931
3.01k
  MCOperand *Cm = MCInst_getOperand(MI, 2);
932
3.01k
  MCOperand *Op2 = MCInst_getOperand(MI, 3);
933
934
3.01k
  unsigned Op1Val = (unsigned)MCOperand_getImm(Op1);
935
3.01k
  unsigned CnVal = (unsigned)MCOperand_getImm(Cn);
936
3.01k
  unsigned CmVal = (unsigned)MCOperand_getImm(Cm);
937
3.01k
  unsigned Op2Val = (unsigned)MCOperand_getImm(Op2);
938
939
3.01k
  Encoding = Op2Val;
940
3.01k
  Encoding |= CmVal << 3;
941
3.01k
  Encoding |= CnVal << 7;
942
3.01k
  Encoding |= Op1Val << 11;
943
944
3.01k
  if (CnVal == 7) {
945
2.18k
    switch (CmVal) {
946
366
      default:
947
366
        return false;
948
949
      // IC aliases
950
239
      case 1: case 5: {
951
239
        const IC *IC = lookupICByEncoding(Encoding);
952
        // if (!IC || !IC->haveFeatures(STI.getFeatureBits()))
953
239
        if (!IC)
954
86
          return false;
955
956
153
        NeedsReg = IC->NeedsReg;
957
153
        Ins = "ic";
958
153
        strncpy(Name, IC->Name, sizeof(Name) - 1);
959
153
      }
960
0
      break;
961
962
      // DC aliases
963
1.23k
      case 4: case 6: case 10: case 11: case 12: case 14: {
964
1.23k
        const DC *DC = lookupDCByEncoding(Encoding);
965
        // if (!DC || !DC->haveFeatures(STI.getFeatureBits()))
966
1.23k
        if (!DC)
967
1.02k
          return false;
968
969
207
        NeedsReg = true;
970
207
        Ins = "dc";
971
207
        strncpy(Name, DC->Name, sizeof(Name) - 1);
972
207
      }
973
0
      break;
974
975
      // AT aliases
976
344
      case 8: case 9: {
977
344
        const AT *AT = lookupATByEncoding(Encoding);
978
        // if (!AT || !AT->haveFeatures(STI.getFeatureBits()))
979
344
        if (!AT)
980
62
          return false;
981
982
282
        NeedsReg = true;
983
282
        Ins = "at";
984
282
        strncpy(Name, AT->Name, sizeof(Name) - 1);
985
282
      }
986
0
      break;
987
2.18k
    }
988
2.18k
  } else if (CnVal == 8) {
989
    // TLBI aliases
990
447
    const TLBI *TLBI = lookupTLBIByEncoding(Encoding);
991
    // if (!TLBI || !TLBI->haveFeatures(STI.getFeatureBits()))
992
447
    if (!TLBI)
993
347
      return false;
994
995
100
    NeedsReg = TLBI->NeedsReg;
996
100
    Ins = "tlbi";
997
100
    strncpy(Name, TLBI->Name, sizeof(Name) - 1);
998
100
  } else
999
385
    return false;
1000
1001
742
  SStream_concat(O, "%s\t%s", Ins, Name);
1002
1003
742
  if (NeedsReg) {
1004
563
    SStream_concat(O, ", %s", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 4)), AArch64_NoRegAltName));
1005
563
  }
1006
1007
742
  MCInst_setOpcodePub(MI, AArch64_map_insn(Ins));
1008
1009
742
  if (MI->csh->detail) {
1010
#if 0
1011
#ifndef CAPSTONE_DIET
1012
    uint8_t access;
1013
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1014
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1015
    MI->ac_idx++;
1016
#endif
1017
#endif
1018
742
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
1019
742
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = AArch64_map_sys_op(Name);
1020
742
    MI->flat_insn->detail->arm64.op_count++;
1021
1022
742
    if (NeedsReg) {
1023
563
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1024
563
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 4));
1025
563
      MI->flat_insn->detail->arm64.op_count++;
1026
563
    }
1027
742
  }
1028
1029
742
  return true;
1030
3.01k
}
1031
1032
static void printOperand(MCInst *MI, unsigned OpNum, SStream *O)
1033
384k
{
1034
384k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1035
1036
384k
  if (MCOperand_isReg(Op)) {
1037
332k
    unsigned Reg = MCOperand_getReg(Op);
1038
1039
332k
    SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
1040
1041
332k
    if (MI->csh->detail) {
1042
332k
      if (MI->csh->doing_mem) {
1043
148k
        if (MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.base == ARM64_REG_INVALID) {
1044
130k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.base = Reg;
1045
130k
        }
1046
17.5k
        else if (MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.index == ARM64_REG_INVALID) {
1047
17.5k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.index = Reg;
1048
17.5k
        }
1049
184k
      } else if (MI->csh->doing_SME_Index) {
1050
        // Access op_count-1 as We want to add info to previous operand, not create a new one
1051
7.21k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count-1].sme_index.base = Reg;
1052
176k
      } else {
1053
176k
#ifndef CAPSTONE_DIET
1054
176k
        uint8_t access;
1055
1056
176k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1057
176k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1058
176k
        MI->ac_idx++;
1059
176k
#endif
1060
176k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1061
176k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
1062
176k
        MI->flat_insn->detail->arm64.op_count++;
1063
176k
      }
1064
332k
    }
1065
332k
  } else if (MCOperand_isImm(Op)) {
1066
51.9k
    int64_t imm = MCOperand_getImm(Op);
1067
1068
51.9k
    if (MI->Opcode == AArch64_ADR) {
1069
2.91k
      imm += MI->address;
1070
2.91k
      printUInt64Bang(O, imm);
1071
49.0k
    } else {
1072
49.0k
      if (MI->csh->doing_mem) {
1073
15.6k
        if (MI->csh->imm_unsigned) {
1074
0
          printUInt64Bang(O, imm);
1075
15.6k
        } else {
1076
15.6k
          printInt64Bang(O, imm);
1077
15.6k
        }
1078
15.6k
      } else
1079
33.4k
        printUInt64Bang(O, imm);
1080
49.0k
    }
1081
1082
51.9k
    if (MI->csh->detail) {
1083
51.9k
      if (MI->csh->doing_mem) {
1084
15.6k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = (int32_t)imm;
1085
36.3k
      } else if (MI->csh->doing_SME_Index) {
1086
        // Access op_count-1 as We want to add info to previous operand, not create a new one
1087
0
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count-1].sme_index.disp = (int32_t)imm; 
1088
36.3k
      } else {
1089
36.3k
#ifndef CAPSTONE_DIET
1090
36.3k
        uint8_t access;
1091
1092
36.3k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1093
36.3k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1094
36.3k
#endif
1095
36.3k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1096
36.3k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = imm;
1097
36.3k
        MI->flat_insn->detail->arm64.op_count++;
1098
36.3k
      }
1099
51.9k
    }
1100
51.9k
  }
1101
384k
}
1102
1103
static void printImm(MCInst *MI, unsigned OpNum, SStream *O)
1104
5.50k
{
1105
5.50k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1106
5.50k
  printUInt64Bang(O, MCOperand_getImm(Op));
1107
1108
5.50k
  if (MI->csh->detail) {
1109
5.50k
#ifndef CAPSTONE_DIET
1110
5.50k
    uint8_t access;
1111
5.50k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1112
5.50k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1113
5.50k
    MI->ac_idx++;
1114
5.50k
#endif
1115
5.50k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1116
5.50k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1117
5.50k
    MI->flat_insn->detail->arm64.op_count++;
1118
5.50k
  }
1119
5.50k
}
1120
1121
static void printImmHex(MCInst *MI, unsigned OpNum, SStream *O)
1122
137
{
1123
137
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1124
137
  printUInt64Bang(O, MCOperand_getImm(Op));
1125
1126
137
  if (MI->csh->detail) {
1127
137
#ifndef CAPSTONE_DIET
1128
137
    uint8_t access;
1129
137
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1130
137
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1131
137
    MI->ac_idx++;
1132
137
#endif
1133
137
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1134
137
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1135
137
    MI->flat_insn->detail->arm64.op_count++;
1136
137
  }
1137
137
}
1138
1139
3.02k
static void printSImm(MCInst *MI, unsigned OpNo, SStream *O, int Size) {
1140
3.02k
  MCOperand *Op = MCInst_getOperand(MI, OpNo);
1141
3.02k
  if (Size == 8)
1142
2.64k
  printInt64Bang(O, (signed char) MCOperand_getImm(Op));
1143
386
  else if (Size == 16)
1144
386
  printInt64Bang(O, (signed short) MCOperand_getImm(Op));
1145
0
  else
1146
0
    printInt64Bang(O, MCOperand_getImm(Op));
1147
1148
3.02k
  if (MI->csh->detail) {
1149
3.02k
#ifndef CAPSTONE_DIET
1150
3.02k
    uint8_t access;
1151
3.02k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1152
3.02k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1153
3.02k
    MI->ac_idx++;
1154
3.02k
#endif
1155
3.02k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1156
3.02k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1157
3.02k
    MI->flat_insn->detail->arm64.op_count++;
1158
3.02k
  }
1159
3.02k
}
1160
1161
static void printPostIncOperand(MCInst *MI, unsigned OpNum, SStream *O,
1162
    unsigned Imm)
1163
28.7k
{
1164
28.7k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1165
1166
28.7k
  if (MCOperand_isReg(Op)) {
1167
28.7k
    unsigned Reg = MCOperand_getReg(Op);
1168
28.7k
    if (Reg == AArch64_XZR) {
1169
0
      printInt32Bang(O, Imm);
1170
1171
0
      if (MI->csh->detail) {
1172
0
#ifndef CAPSTONE_DIET
1173
0
        uint8_t access;
1174
1175
0
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1176
0
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1177
0
        MI->ac_idx++;
1178
0
#endif
1179
0
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1180
0
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Imm;
1181
0
        MI->flat_insn->detail->arm64.op_count++;
1182
0
      }
1183
28.7k
    } else {
1184
28.7k
      SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
1185
1186
28.7k
      if (MI->csh->detail) {
1187
28.7k
#ifndef CAPSTONE_DIET
1188
28.7k
        uint8_t access;
1189
1190
28.7k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1191
28.7k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1192
28.7k
        MI->ac_idx++;
1193
28.7k
#endif
1194
28.7k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1195
28.7k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
1196
28.7k
        MI->flat_insn->detail->arm64.op_count++;
1197
28.7k
      }
1198
28.7k
    }
1199
28.7k
  }
1200
  //llvm_unreachable("unknown operand kind in printPostIncOperand64");
1201
28.7k
}
1202
1203
static void printVRegOperand(MCInst *MI, unsigned OpNum, SStream *O)
1204
57.4k
{
1205
57.4k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1206
  //assert(Op.isReg() && "Non-register vreg operand!");
1207
57.4k
  unsigned Reg = MCOperand_getReg(Op);
1208
1209
57.4k
  SStream_concat0(O, getRegisterName(Reg, AArch64_vreg));
1210
1211
57.4k
  if (MI->csh->detail) {
1212
57.4k
#ifndef CAPSTONE_DIET
1213
57.4k
    uint8_t access;
1214
57.4k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1215
57.4k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1216
57.4k
    MI->ac_idx++;
1217
57.4k
#endif
1218
57.4k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1219
57.4k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = AArch64_map_vregister(Reg);
1220
57.4k
    MI->flat_insn->detail->arm64.op_count++;
1221
57.4k
  }
1222
57.4k
}
1223
1224
static void printSysCROperand(MCInst *MI, unsigned OpNum, SStream *O)
1225
4.77k
{
1226
4.77k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1227
  //assert(Op.isImm() && "System instruction C[nm] operands must be immediates!");
1228
4.77k
  SStream_concat(O, "c%u", MCOperand_getImm(Op));
1229
1230
4.77k
  if (MI->csh->detail) {
1231
4.77k
#ifndef CAPSTONE_DIET
1232
4.77k
    uint8_t access;
1233
1234
4.77k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1235
4.77k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1236
4.77k
    MI->ac_idx++;
1237
4.77k
#endif
1238
4.77k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_CIMM;
1239
4.77k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1240
4.77k
    MI->flat_insn->detail->arm64.op_count++;
1241
4.77k
  }
1242
4.77k
}
1243
1244
static void printAddSubImm(MCInst *MI, unsigned OpNum, SStream *O)
1245
3.65k
{
1246
3.65k
  MCOperand *MO = MCInst_getOperand(MI, OpNum);
1247
3.65k
  if (MCOperand_isImm(MO)) {
1248
3.65k
    unsigned Val = (MCOperand_getImm(MO) & 0xfff);
1249
    //assert(Val == MO.getImm() && "Add/sub immediate out of range!");
1250
3.65k
    unsigned Shift = AArch64_AM_getShiftValue((int)MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1)));
1251
1252
3.65k
    printInt32Bang(O, Val);
1253
1254
3.65k
    if (MI->csh->detail) {
1255
3.65k
#ifndef CAPSTONE_DIET
1256
3.65k
      uint8_t access;
1257
1258
3.65k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1259
3.65k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1260
3.65k
      MI->ac_idx++;
1261
3.65k
#endif
1262
3.65k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1263
3.65k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
1264
3.65k
      MI->flat_insn->detail->arm64.op_count++;
1265
3.65k
    }
1266
1267
3.65k
    if (Shift != 0)
1268
1.87k
      printShifter(MI, OpNum + 1, O);
1269
3.65k
  }
1270
3.65k
}
1271
1272
static void printLogicalImm32(MCInst *MI, unsigned OpNum, SStream *O)
1273
3.68k
{
1274
3.68k
  int64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1275
1276
3.68k
  Val = AArch64_AM_decodeLogicalImmediate(Val, 32);
1277
3.68k
  printUInt32Bang(O, (int)Val);
1278
1279
3.68k
  if (MI->csh->detail) {
1280
3.68k
#ifndef CAPSTONE_DIET
1281
3.68k
    uint8_t access;
1282
1283
3.68k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1284
3.68k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1285
3.68k
    MI->ac_idx++;
1286
3.68k
#endif
1287
3.68k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1288
3.68k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
1289
3.68k
    MI->flat_insn->detail->arm64.op_count++;
1290
3.68k
  }
1291
3.68k
}
1292
1293
static void printLogicalImm64(MCInst *MI, unsigned OpNum, SStream *O)
1294
2.52k
{
1295
2.52k
  int64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1296
2.52k
  Val = AArch64_AM_decodeLogicalImmediate(Val, 64);
1297
1298
2.52k
  switch(MI->flat_insn->id) {
1299
1.52k
    default:
1300
1.52k
      printInt64Bang(O, Val);
1301
1.52k
      break;
1302
1303
210
    case ARM64_INS_ORR:
1304
870
    case ARM64_INS_AND:
1305
1.00k
    case ARM64_INS_EOR:
1306
1.00k
    case ARM64_INS_TST:
1307
      // do not print number in negative form
1308
1.00k
      if (Val >= 0 && Val <= HEX_THRESHOLD)
1309
41
        SStream_concat(O, "#%u", (int)Val);
1310
961
      else
1311
961
        SStream_concat(O, "#0x%"PRIx64, Val);
1312
1.00k
      break;
1313
2.52k
  }
1314
1315
2.52k
  if (MI->csh->detail) {
1316
2.52k
#ifndef CAPSTONE_DIET
1317
2.52k
    uint8_t access;
1318
1319
2.52k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1320
2.52k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1321
2.52k
    MI->ac_idx++;
1322
2.52k
#endif
1323
2.52k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1324
2.52k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = (int64_t)Val;
1325
2.52k
    MI->flat_insn->detail->arm64.op_count++;
1326
2.52k
  }
1327
2.52k
}
1328
1329
static void printShifter(MCInst *MI, unsigned OpNum, SStream *O)
1330
14.1k
{
1331
14.1k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1332
1333
  // LSL #0 should not be printed.
1334
14.1k
  if (AArch64_AM_getShiftType(Val) == AArch64_AM_LSL &&
1335
7.66k
      AArch64_AM_getShiftValue(Val) == 0)
1336
1.27k
    return;
1337
1338
12.8k
  SStream_concat(O, ", %s ", AArch64_AM_getShiftExtendName(AArch64_AM_getShiftType(Val)));
1339
12.8k
  printInt32BangDec(O, AArch64_AM_getShiftValue(Val));
1340
1341
12.8k
  if (MI->csh->detail) {
1342
12.8k
    arm64_shifter shifter = ARM64_SFT_INVALID;
1343
1344
12.8k
    switch(AArch64_AM_getShiftType(Val)) {
1345
0
      default:  // never reach
1346
6.38k
      case AArch64_AM_LSL:
1347
6.38k
        shifter = ARM64_SFT_LSL;
1348
6.38k
        break;
1349
1350
2.58k
      case AArch64_AM_LSR:
1351
2.58k
        shifter = ARM64_SFT_LSR;
1352
2.58k
        break;
1353
1354
2.69k
      case AArch64_AM_ASR:
1355
2.69k
        shifter = ARM64_SFT_ASR;
1356
2.69k
        break;
1357
1358
935
      case AArch64_AM_ROR:
1359
935
        shifter = ARM64_SFT_ROR;
1360
935
        break;
1361
1362
270
      case AArch64_AM_MSL:
1363
270
        shifter = ARM64_SFT_MSL;
1364
270
        break;
1365
12.8k
    }
1366
1367
12.8k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.type = shifter;
1368
12.8k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.value = AArch64_AM_getShiftValue(Val);
1369
12.8k
  }
1370
12.8k
}
1371
1372
static void printShiftedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1373
8.32k
{
1374
8.32k
  SStream_concat0(O, getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, OpNum)), AArch64_NoRegAltName));
1375
1376
8.32k
  if (MI->csh->detail) {
1377
8.32k
#ifndef CAPSTONE_DIET
1378
8.32k
    uint8_t access;
1379
8.32k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1380
8.32k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1381
8.32k
    MI->ac_idx++;
1382
8.32k
#endif
1383
8.32k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1384
8.32k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1385
8.32k
    MI->flat_insn->detail->arm64.op_count++;
1386
8.32k
  }
1387
1388
8.32k
  printShifter(MI, OpNum + 1, O);
1389
8.32k
}
1390
1391
static void printArithExtend(MCInst *MI, unsigned OpNum, SStream *O)
1392
4.38k
{
1393
4.38k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1394
4.38k
  AArch64_AM_ShiftExtendType ExtType = AArch64_AM_getArithExtendType(Val);
1395
4.38k
  unsigned ShiftVal = AArch64_AM_getArithShiftValue(Val);
1396
1397
  // If the destination or first source register operand is [W]SP, print
1398
  // UXTW/UXTX as LSL, and if the shift amount is also zero, print nothing at
1399
  // all.
1400
4.38k
  if (ExtType == AArch64_AM_UXTW || ExtType == AArch64_AM_UXTX) {
1401
2.26k
    unsigned Dest = MCOperand_getReg(MCInst_getOperand(MI, 0));
1402
2.26k
    unsigned Src1 = MCOperand_getReg(MCInst_getOperand(MI, 1));
1403
1404
2.26k
    if (((Dest == AArch64_SP || Src1 == AArch64_SP) &&
1405
1.06k
          ExtType == AArch64_AM_UXTX) ||
1406
2.13k
        ((Dest == AArch64_WSP || Src1 == AArch64_WSP) &&
1407
635
         ExtType == AArch64_AM_UXTW)) {
1408
315
      if (ShiftVal != 0) {
1409
315
        SStream_concat0(O, ", lsl ");
1410
315
        printInt32Bang(O, ShiftVal);
1411
1412
315
        if (MI->csh->detail) {
1413
315
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.type = ARM64_SFT_LSL;
1414
315
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.value = ShiftVal;
1415
315
        }
1416
315
      }
1417
1418
315
      return;
1419
315
    }
1420
2.26k
  }
1421
1422
4.06k
  SStream_concat(O, ", %s", AArch64_AM_getShiftExtendName(ExtType));
1423
1424
4.06k
  if (MI->csh->detail) {
1425
4.06k
    arm64_extender ext = ARM64_EXT_INVALID;
1426
4.06k
    switch(ExtType) {
1427
0
      default:  // never reach
1428
1429
155
      case AArch64_AM_UXTB:
1430
155
        ext = ARM64_EXT_UXTB;
1431
155
        break;
1432
1433
464
      case AArch64_AM_UXTH:
1434
464
        ext = ARM64_EXT_UXTH;
1435
464
        break;
1436
1437
1.37k
      case AArch64_AM_UXTW:
1438
1.37k
        ext = ARM64_EXT_UXTW;
1439
1.37k
        break;
1440
1441
571
      case AArch64_AM_UXTX:
1442
571
        ext = ARM64_EXT_UXTX;
1443
571
        break;
1444
1445
317
      case AArch64_AM_SXTB:
1446
317
        ext = ARM64_EXT_SXTB;
1447
317
        break;
1448
1449
628
      case AArch64_AM_SXTH:
1450
628
        ext = ARM64_EXT_SXTH;
1451
628
        break;
1452
1453
46
      case AArch64_AM_SXTW:
1454
46
        ext = ARM64_EXT_SXTW;
1455
46
        break;
1456
1457
506
      case AArch64_AM_SXTX:
1458
506
        ext = ARM64_EXT_SXTX;
1459
506
        break;
1460
4.06k
    }
1461
1462
4.06k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].ext = ext;
1463
4.06k
  }
1464
1465
4.06k
  if (ShiftVal != 0) {
1466
3.80k
    SStream_concat0(O, " ");
1467
3.80k
    printInt32Bang(O, ShiftVal);
1468
1469
3.80k
    if (MI->csh->detail) {
1470
3.80k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.type = ARM64_SFT_LSL;
1471
3.80k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.value = ShiftVal;
1472
3.80k
    }
1473
3.80k
  }
1474
4.06k
}
1475
1476
static void printExtendedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1477
3.24k
{
1478
3.24k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1479
1480
3.24k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
1481
1482
3.24k
  if (MI->csh->detail) {
1483
3.24k
#ifndef CAPSTONE_DIET
1484
3.24k
    uint8_t access;
1485
3.24k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1486
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1487
3.24k
    MI->ac_idx++;
1488
3.24k
#endif
1489
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1490
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
1491
3.24k
    MI->flat_insn->detail->arm64.op_count++;
1492
3.24k
  }
1493
1494
3.24k
  printArithExtend(MI, OpNum + 1, O);
1495
3.24k
}
1496
1497
static void printMemExtendImpl(MCInst *MI, bool SignExtend, bool DoShift, unsigned Width,
1498
             char SrcRegKind, SStream *O)
1499
17.0k
{
1500
  // sxtw, sxtx, uxtw or lsl (== uxtx)
1501
17.0k
  bool IsLSL = !SignExtend && SrcRegKind == 'x';
1502
17.0k
  if (IsLSL) {
1503
5.41k
    SStream_concat0(O, "lsl");
1504
1505
5.41k
    if (MI->csh->detail) {
1506
5.41k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].shift.type = ARM64_SFT_LSL;
1507
5.41k
    }
1508
11.6k
  } else {
1509
11.6k
    SStream_concat(O, "%cxt%c", (SignExtend ? 's' : 'u'), SrcRegKind);
1510
1511
11.6k
    if (MI->csh->detail) {
1512
11.6k
      if (!SignExtend) {
1513
6.26k
        switch(SrcRegKind) {
1514
0
          default: break;
1515
0
          case 'b':
1516
0
               MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_UXTB;
1517
0
               break;
1518
0
          case 'h':
1519
0
               MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_UXTH;
1520
0
               break;
1521
6.26k
          case 'w':
1522
6.26k
               MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_UXTW;
1523
6.26k
               break;
1524
6.26k
        }
1525
6.26k
      } else {
1526
5.35k
          switch(SrcRegKind) {
1527
0
            default: break;
1528
0
            case 'b':
1529
0
              MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_SXTB;
1530
0
              break;
1531
0
            case 'h':
1532
0
              MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_SXTH;
1533
0
              break;
1534
3.89k
            case 'w':
1535
3.89k
              MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_SXTW;
1536
3.89k
              break;
1537
1.46k
            case 'x':
1538
1.46k
              MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_SXTX;
1539
1.46k
              break;
1540
5.35k
          }
1541
5.35k
      }
1542
11.6k
    }
1543
11.6k
  }
1544
1545
17.0k
  if (DoShift || IsLSL) {
1546
12.1k
    SStream_concat(O, " #%u", Log2_32(Width / 8));
1547
1548
12.1k
    if (MI->csh->detail) {
1549
12.1k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].shift.type = ARM64_SFT_LSL;
1550
12.1k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].shift.value = Log2_32(Width / 8);
1551
12.1k
    }
1552
12.1k
  }
1553
17.0k
}
1554
1555
static void printMemExtend(MCInst *MI, unsigned OpNum, SStream *O, char SrcRegKind, unsigned Width)
1556
5.52k
{
1557
5.52k
  unsigned SignExtend = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1558
5.52k
  unsigned DoShift = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1));
1559
1560
5.52k
  printMemExtendImpl(MI, SignExtend, DoShift, Width, SrcRegKind, O);
1561
5.52k
}
1562
1563
static void printRegWithShiftExtend(MCInst *MI, unsigned OpNum, SStream *O,
1564
            bool SignExtend, int ExtWidth,
1565
            char SrcRegKind, char Suffix)
1566
13.5k
{
1567
13.5k
  bool DoShift;
1568
1569
13.5k
  printOperand(MI, OpNum, O);
1570
1571
13.5k
  if (Suffix == 's' || Suffix == 'd')
1572
8.62k
    SStream_concat(O, ".%c", Suffix);
1573
1574
13.5k
  DoShift = ExtWidth != 8;
1575
13.5k
  if (SignExtend || DoShift || SrcRegKind == 'w') {
1576
11.5k
    SStream_concat0(O, ", ");
1577
11.5k
    printMemExtendImpl(MI, SignExtend, DoShift, ExtWidth, SrcRegKind, O);
1578
11.5k
  }
1579
13.5k
}
1580
1581
static void printCondCode(MCInst *MI, unsigned OpNum, SStream *O)
1582
2.59k
{
1583
2.59k
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1584
2.59k
  SStream_concat0(O, getCondCodeName(CC));
1585
1586
2.59k
  if (MI->csh->detail)
1587
2.59k
    MI->flat_insn->detail->arm64.cc = (arm64_cc)(CC + 1);
1588
2.59k
}
1589
1590
static void printInverseCondCode(MCInst *MI, unsigned OpNum, SStream *O)
1591
1.49k
{
1592
1.49k
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1593
1.49k
  SStream_concat0(O, getCondCodeName(getInvertedCondCode(CC)));
1594
1595
1.49k
  if (MI->csh->detail) {
1596
1.49k
    MI->flat_insn->detail->arm64.cc = (arm64_cc)(getInvertedCondCode(CC) + 1);
1597
1.49k
  }
1598
1.49k
}
1599
1600
static void printImmScale(MCInst *MI, unsigned OpNum, SStream *O, int Scale)
1601
15.8k
{
1602
15.8k
  int64_t val = Scale * MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1603
1604
15.8k
  printInt64Bang(O, val);
1605
1606
15.8k
  if (MI->csh->detail) {
1607
15.8k
    if (MI->csh->doing_mem) {
1608
12.8k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = (int32_t)val;
1609
12.8k
    } else {
1610
2.96k
#ifndef CAPSTONE_DIET
1611
2.96k
      uint8_t access;
1612
1613
2.96k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1614
2.96k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1615
2.96k
      MI->ac_idx++;
1616
2.96k
#endif
1617
2.96k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1618
2.96k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = val;
1619
2.96k
      MI->flat_insn->detail->arm64.op_count++;
1620
2.96k
    }
1621
15.8k
  }
1622
15.8k
}
1623
1624
static void printUImm12Offset(MCInst *MI, unsigned OpNum, SStream *O, unsigned Scale)
1625
7.76k
{
1626
7.76k
  MCOperand *MO = MCInst_getOperand(MI, OpNum);
1627
1628
7.76k
  if (MCOperand_isImm(MO)) {
1629
7.76k
    int64_t val = Scale * MCOperand_getImm(MO);
1630
7.76k
    printInt64Bang(O, val);
1631
1632
7.76k
    if (MI->csh->detail) {
1633
7.76k
      if (MI->csh->doing_mem) {
1634
7.76k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = (int32_t)val;
1635
7.76k
      } else {
1636
0
#ifndef CAPSTONE_DIET
1637
0
        uint8_t access;
1638
1639
0
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1640
0
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1641
0
        MI->ac_idx++;
1642
0
#endif
1643
0
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1644
0
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = (int)val;
1645
0
        MI->flat_insn->detail->arm64.op_count++;
1646
0
      }
1647
7.76k
    }
1648
7.76k
  }
1649
7.76k
}
1650
1651
#if 0
1652
static void printAMIndexedWB(MCInst *MI, unsigned OpNum, SStream *O, unsigned int Scale)
1653
{
1654
  MCOperand *MO = MCInst_getOperand(MI, OpNum + 1);
1655
1656
  SStream_concat(O, "[%s", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, OpNum)), AArch64_NoRegAltName));
1657
1658
  if (MCOperand_isImm(MO)) {
1659
    int64_t val = Scale * MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1660
    printInt64Bang(O, val);
1661
  // } else {
1662
  //   // assert(MO1.isExpr() && "Unexpected operand type!");
1663
  //   SStream_concat0(O, ", ");
1664
  //   MO1.getExpr()->print(O, &MAI);
1665
  }
1666
1667
  SStream_concat0(O, "]");
1668
}
1669
#endif
1670
1671
// IsSVEPrefetch = false
1672
static void printPrefetchOp(MCInst *MI, unsigned OpNum, SStream *O, bool IsSVEPrefetch)
1673
6.12k
{
1674
6.12k
  unsigned prfop = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1675
1676
6.12k
  if (IsSVEPrefetch) {
1677
4.75k
    const SVEPRFM *PRFM = lookupSVEPRFMByEncoding(prfop);
1678
4.75k
    if (PRFM)
1679
4.05k
      SStream_concat0(O, PRFM->Name);
1680
1681
4.75k
    return;
1682
4.75k
  } else {
1683
1.36k
    const PRFM *PRFM = lookupPRFMByEncoding(prfop);
1684
1.36k
    if (PRFM)
1685
743
      SStream_concat0(O, PRFM->Name);
1686
1687
1.36k
    return;
1688
1.36k
  }
1689
1690
  // FIXME: set OpcodePub?
1691
1692
0
  printInt32Bang(O, prfop);
1693
1694
0
  if (MI->csh->detail) {
1695
0
#ifndef CAPSTONE_DIET
1696
0
    uint8_t access;
1697
0
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1698
0
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1699
0
    MI->ac_idx++;
1700
0
#endif
1701
0
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1702
0
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = prfop;
1703
0
    MI->flat_insn->detail->arm64.op_count++;
1704
0
  }
1705
0
}
1706
1707
static void printPSBHintOp(MCInst *MI, unsigned OpNum, SStream *O)
1708
811
{
1709
811
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1710
811
  unsigned int psbhintop = MCOperand_getImm(Op);
1711
1712
811
  const PSB *PSB = lookupPSBByEncoding(psbhintop);
1713
811
  if (PSB)
1714
811
    SStream_concat0(O, PSB->Name);
1715
0
  else
1716
0
    printUInt32Bang(O, psbhintop);
1717
811
}
1718
1719
561
static void printBTIHintOp(MCInst *MI, unsigned OpNum, SStream *O) {
1720
561
  unsigned btihintop = MCOperand_getImm(MCInst_getOperand(MI, OpNum)) ^ 32;
1721
1722
561
  const BTI *BTI = lookupBTIByEncoding(btihintop);
1723
561
  if (BTI)
1724
561
  SStream_concat0(O, BTI->Name);
1725
0
  else
1726
0
  printUInt32Bang(O, btihintop);
1727
561
}
1728
1729
static void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1730
1.85k
{
1731
1.85k
  MCOperand *MO = MCInst_getOperand(MI, OpNum);
1732
1.85k
  float FPImm = MCOperand_isFPImm(MO) ? MCOperand_getFPImm(MO) : AArch64_AM_getFPImmFloat((int)MCOperand_getImm(MO));
1733
1734
  // 8 decimal places are enough to perfectly represent permitted floats.
1735
#if defined(_KERNEL_MODE)
1736
  // Issue #681: Windows kernel does not support formatting float point
1737
  SStream_concat0(O, "#<float_point_unsupported>");
1738
#else
1739
1.85k
  SStream_concat(O, "#%.8f", FPImm);
1740
1.85k
#endif
1741
1742
1.85k
  if (MI->csh->detail) {
1743
1.85k
#ifndef CAPSTONE_DIET
1744
1.85k
    uint8_t access;
1745
1746
1.85k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1747
1.85k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1748
1.85k
    MI->ac_idx++;
1749
1.85k
#endif
1750
1.85k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_FP;
1751
1.85k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].fp = FPImm;
1752
1.85k
    MI->flat_insn->detail->arm64.op_count++;
1753
1.85k
  }
1754
1.85k
}
1755
1756
//static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride = 1)
1757
static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride)
1758
172k
{
1759
345k
  while (Stride--) {
1760
172k
    if (Reg >= AArch64_Q0 && Reg <= AArch64_Q30) // AArch64_Q0 .. AArch64_Q30
1761
151k
      Reg += 1;
1762
21.2k
    else if (Reg == AArch64_Q31) // Vector lists can wrap around.
1763
6.41k
      Reg = AArch64_Q0;
1764
14.8k
    else if (Reg >= AArch64_Z0 && Reg <= AArch64_Z30) // AArch64_Z0 .. AArch64_Z30
1765
14.1k
      Reg += 1;
1766
669
    else if (Reg == AArch64_Z31) // Vector lists can wrap around.
1767
669
      Reg = AArch64_Z0;
1768
172k
  }
1769
1770
172k
  return Reg;
1771
172k
}
1772
1773
static void printGPRSeqPairsClassOperand(MCInst *MI, unsigned OpNum, SStream *O, unsigned int size)
1774
3.24k
{
1775
  // static_assert(size == 64 || size == 32,
1776
  //    "Template parameter must be either 32 or 64");
1777
3.24k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1778
3.24k
  unsigned Sube = (size == 32) ? AArch64_sube32 : AArch64_sube64;
1779
3.24k
  unsigned Subo = (size == 32) ? AArch64_subo32 : AArch64_subo64;
1780
3.24k
  unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube);
1781
3.24k
  unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo);
1782
1783
3.24k
  SStream_concat(O, "%s, %s", getRegisterName(Even, AArch64_NoRegAltName),
1784
3.24k
      getRegisterName(Odd, AArch64_NoRegAltName));
1785
1786
3.24k
  if (MI->csh->detail) {
1787
3.24k
#ifndef CAPSTONE_DIET
1788
3.24k
    uint8_t access;
1789
1790
3.24k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1791
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1792
3.24k
    MI->ac_idx++;
1793
3.24k
#endif
1794
1795
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1796
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Even;
1797
3.24k
    MI->flat_insn->detail->arm64.op_count++;
1798
1799
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1800
3.24k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Odd;
1801
3.24k
    MI->flat_insn->detail->arm64.op_count++;
1802
3.24k
  }
1803
3.24k
}
1804
1805
static void printVectorList(MCInst *MI, unsigned OpNum, SStream *O,
1806
    char *LayoutSuffix, MCRegisterInfo *MRI, arm64_vas vas)
1807
68.8k
{
1808
1.01M
#define GETREGCLASS_CONTAIN0(_class, _reg) MCRegisterClass_contains(MCRegisterInfo_getRegClass(MRI, _class), _reg)
1809
68.8k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1810
68.8k
  unsigned NumRegs = 1, FirstReg, i;
1811
1812
68.8k
  SStream_concat0(O, "{");
1813
1814
  // Work out how many registers there are in the list (if there is an actual
1815
  // list).
1816
68.8k
  if (GETREGCLASS_CONTAIN0(AArch64_DDRegClassID , Reg) ||
1817
65.9k
      GETREGCLASS_CONTAIN0(AArch64_ZPR2RegClassID, Reg) ||
1818
65.0k
      GETREGCLASS_CONTAIN0(AArch64_QQRegClassID, Reg))
1819
14.4k
    NumRegs = 2;
1820
54.4k
  else if (GETREGCLASS_CONTAIN0(AArch64_DDDRegClassID, Reg) ||
1821
50.8k
      GETREGCLASS_CONTAIN0(AArch64_ZPR3RegClassID, Reg) ||
1822
49.9k
      GETREGCLASS_CONTAIN0(AArch64_QQQRegClassID, Reg))
1823
17.3k
    NumRegs = 3;
1824
37.1k
  else if (GETREGCLASS_CONTAIN0(AArch64_DDDDRegClassID, Reg) ||
1825
31.7k
      GETREGCLASS_CONTAIN0(AArch64_ZPR4RegClassID, Reg) ||
1826
31.0k
      GETREGCLASS_CONTAIN0(AArch64_QQQQRegClassID, Reg))
1827
18.2k
    NumRegs = 4;
1828
1829
  // Now forget about the list and find out what the first register is.
1830
68.8k
  if ((FirstReg = MCRegisterInfo_getSubReg(MRI, Reg, AArch64_dsub0)))
1831
11.9k
    Reg = FirstReg;
1832
56.9k
  else if ((FirstReg = MCRegisterInfo_getSubReg(MRI, Reg, AArch64_qsub0)))
1833
35.6k
    Reg = FirstReg;
1834
21.3k
  else if ((FirstReg = MCRegisterInfo_getSubReg(MRI, Reg, AArch64_zsub0)))
1835
2.41k
    Reg = FirstReg;
1836
1837
  // If it's a D-reg, we need to promote it to the equivalent Q-reg before
1838
  // printing (otherwise getRegisterName fails).
1839
68.8k
  if (GETREGCLASS_CONTAIN0(AArch64_FPR64RegClassID, Reg)) {
1840
13.2k
    const MCRegisterClass *FPR128RC = MCRegisterInfo_getRegClass(MRI, AArch64_FPR128RegClassID);
1841
13.2k
    Reg = MCRegisterInfo_getMatchingSuperReg(MRI, Reg, AArch64_dsub, FPR128RC);
1842
13.2k
  }
1843
1844
241k
  for (i = 0; i < NumRegs; ++i, Reg = getNextVectorRegister(Reg, 1)) {
1845
172k
    bool isZReg = GETREGCLASS_CONTAIN0(AArch64_ZPRRegClassID, Reg);
1846
172k
    if (isZReg)
1847
14.8k
      SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_NoRegAltName), LayoutSuffix);
1848
157k
    else
1849
157k
      SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_vreg), LayoutSuffix);
1850
1851
172k
    if (MI->csh->detail) {
1852
172k
#ifndef CAPSTONE_DIET
1853
172k
      uint8_t access;
1854
1855
172k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1856
172k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1857
172k
      MI->ac_idx++;
1858
172k
#endif
1859
172k
      unsigned regForDetail = isZReg ? Reg : AArch64_map_vregister(Reg);
1860
172k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1861
172k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = regForDetail;
1862
172k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].vas = vas;
1863
172k
      MI->flat_insn->detail->arm64.op_count++;
1864
172k
    }
1865
1866
172k
    if (i + 1 != NumRegs)
1867
103k
      SStream_concat0(O, ", ");
1868
172k
  }
1869
1870
68.8k
  SStream_concat0(O, "}");
1871
68.8k
}
1872
1873
static void printTypedVectorList(MCInst *MI, unsigned OpNum, SStream *O, unsigned NumLanes, char LaneKind)
1874
68.8k
{
1875
68.8k
  char Suffix[32];
1876
68.8k
  arm64_vas vas = 0;
1877
1878
68.8k
  if (NumLanes) {
1879
31.4k
    cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, LaneKind);
1880
1881
31.4k
    switch(LaneKind) {
1882
0
      default: break;
1883
8.37k
      case 'b':
1884
8.37k
        switch(NumLanes) {
1885
0
          default: break;
1886
0
          case 1:
1887
0
               vas = ARM64_VAS_1B;
1888
0
               break;
1889
0
          case 4:
1890
0
               vas = ARM64_VAS_4B;
1891
0
               break;
1892
3.10k
          case 8:
1893
3.10k
               vas = ARM64_VAS_8B;
1894
3.10k
               break;
1895
5.27k
          case 16:
1896
5.27k
               vas = ARM64_VAS_16B;
1897
5.27k
               break;
1898
8.37k
        }
1899
8.37k
        break;
1900
8.72k
      case 'h':
1901
8.72k
        switch(NumLanes) {
1902
0
          default: break;
1903
0
          case 1:
1904
0
               vas = ARM64_VAS_1H;
1905
0
               break;
1906
0
          case 2:
1907
0
               vas = ARM64_VAS_2H;
1908
0
               break;
1909
3.80k
          case 4:
1910
3.80k
               vas = ARM64_VAS_4H;
1911
3.80k
               break;
1912
4.92k
          case 8:
1913
4.92k
               vas = ARM64_VAS_8H;
1914
4.92k
               break;
1915
8.72k
        }
1916
8.72k
        break;
1917
8.72k
      case 's':
1918
8.36k
        switch(NumLanes) {
1919
0
          default: break;
1920
0
          case 1:
1921
0
               vas = ARM64_VAS_1S;
1922
0
               break;
1923
3.16k
          case 2:
1924
3.16k
               vas = ARM64_VAS_2S;
1925
3.16k
               break;
1926
5.20k
          case 4:
1927
5.20k
               vas = ARM64_VAS_4S;
1928
5.20k
               break;
1929
8.36k
        }
1930
8.36k
        break;
1931
8.36k
      case 'd':
1932
5.94k
        switch(NumLanes) {
1933
0
          default: break;
1934
3.15k
          case 1:
1935
3.15k
               vas = ARM64_VAS_1D;
1936
3.15k
               break;
1937
2.78k
          case 2:
1938
2.78k
               vas = ARM64_VAS_2D;
1939
2.78k
               break;
1940
5.94k
        }
1941
5.94k
        break;
1942
5.94k
      case 'q':
1943
0
        switch(NumLanes) {
1944
0
          default: break;
1945
0
          case 1:
1946
0
               vas = ARM64_VAS_1Q;
1947
0
               break;
1948
0
        }
1949
0
        break;
1950
31.4k
    }
1951
37.4k
  } else {
1952
37.4k
    cs_snprintf(Suffix, sizeof(Suffix), ".%c", LaneKind);
1953
1954
37.4k
    switch(LaneKind) {
1955
0
      default: break;
1956
7.89k
      case 'b':
1957
7.89k
           vas = ARM64_VAS_1B;
1958
7.89k
           break;
1959
8.53k
      case 'h':
1960
8.53k
           vas = ARM64_VAS_1H;
1961
8.53k
           break;
1962
10.9k
      case 's':
1963
10.9k
           vas = ARM64_VAS_1S;
1964
10.9k
           break;
1965
10.1k
      case 'd':
1966
10.1k
           vas = ARM64_VAS_1D;
1967
10.1k
           break;
1968
0
      case 'q':
1969
0
           vas = ARM64_VAS_1Q;
1970
0
           break;
1971
37.4k
    }
1972
37.4k
  }
1973
1974
68.8k
  printVectorList(MI, OpNum, O, Suffix, MI->MRI, vas);
1975
68.8k
}
1976
1977
static void printVectorIndex(MCInst *MI, unsigned OpNum, SStream *O)
1978
40.4k
{
1979
40.4k
  SStream_concat0(O, "[");
1980
40.4k
  printInt32(O, (int)MCOperand_getImm(MCInst_getOperand(MI, OpNum)));
1981
40.4k
  SStream_concat0(O, "]");
1982
1983
40.4k
  if (MI->csh->detail) {
1984
40.4k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].vector_index = (int)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1985
40.4k
  }
1986
40.4k
}
1987
1988
static void printAlignedLabel(MCInst *MI, unsigned OpNum, SStream *O)
1989
10.4k
{
1990
10.4k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1991
1992
  // If the label has already been resolved to an immediate offset (say, when
1993
  // we're running the disassembler), just print the immediate.
1994
10.4k
  if (MCOperand_isImm(Op)) {
1995
10.4k
    uint64_t imm = (MCOperand_getImm(Op) * 4) + MI->address;
1996
10.4k
    printUInt64Bang(O, imm);
1997
1998
10.4k
    if (MI->csh->detail) {
1999
10.4k
#ifndef CAPSTONE_DIET
2000
10.4k
      uint8_t access;
2001
2002
10.4k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2003
10.4k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2004
10.4k
      MI->ac_idx++;
2005
10.4k
#endif
2006
10.4k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2007
10.4k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = imm;
2008
10.4k
      MI->flat_insn->detail->arm64.op_count++;
2009
10.4k
    }
2010
10.4k
  }
2011
10.4k
}
2012
2013
static void printAdrpLabel(MCInst *MI, unsigned OpNum, SStream *O)
2014
1.82k
{
2015
1.82k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
2016
2017
1.82k
  if (MCOperand_isImm(Op)) {
2018
    // ADRP sign extends a 21-bit offset, shifts it left by 12
2019
    // and adds it to the value of the PC with its bottom 12 bits cleared
2020
1.82k
    uint64_t imm = (MCOperand_getImm(Op) * 0x1000) + (MI->address & ~0xfff);
2021
1.82k
    printUInt64Bang(O, imm);
2022
2023
1.82k
    if (MI->csh->detail) {
2024
1.82k
#ifndef CAPSTONE_DIET
2025
1.82k
      uint8_t access;
2026
2027
1.82k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2028
1.82k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2029
1.82k
      MI->ac_idx++;
2030
1.82k
#endif
2031
1.82k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2032
1.82k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = imm;
2033
1.82k
      MI->flat_insn->detail->arm64.op_count++;
2034
1.82k
    }
2035
1.82k
  }
2036
1.82k
}
2037
2038
static void printBarrierOption(MCInst *MI, unsigned OpNum, SStream *O)
2039
325
{
2040
325
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2041
325
  unsigned Opcode = MCInst_getOpcode(MI);
2042
325
  const char *Name = NULL;
2043
2044
325
  if (Opcode == AArch64_ISB) {
2045
150
    const ISB *ISB = lookupISBByEncoding(Val);
2046
150
    Name = ISB ? ISB->Name : NULL;
2047
175
  } else if (Opcode == AArch64_TSB) {
2048
0
    const TSB *TSB = lookupTSBByEncoding(Val);
2049
0
    Name = TSB ? TSB->Name : NULL;
2050
175
  } else {
2051
175
    const DB *DB = lookupDBByEncoding(Val);
2052
175
    Name = DB ? DB->Name : NULL;
2053
175
  }
2054
2055
325
  if (Name) {
2056
83
    SStream_concat0(O, Name);
2057
2058
83
    if (MI->csh->detail) {
2059
83
#ifndef CAPSTONE_DIET
2060
83
      uint8_t access;
2061
2062
83
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2063
83
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2064
83
      MI->ac_idx++;
2065
83
#endif
2066
83
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_BARRIER;
2067
83
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].barrier = Val;
2068
83
      MI->flat_insn->detail->arm64.op_count++;
2069
83
    }
2070
242
  } else {
2071
242
    printUInt32Bang(O, Val);
2072
2073
242
    if (MI->csh->detail) {
2074
242
#ifndef CAPSTONE_DIET
2075
242
      uint8_t access;
2076
2077
242
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2078
242
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2079
242
      MI->ac_idx++;
2080
242
#endif
2081
242
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2082
242
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
2083
242
      MI->flat_insn->detail->arm64.op_count++;
2084
242
    }
2085
242
  }
2086
325
}
2087
2088
19
static void printBarriernXSOption(MCInst *MI, unsigned OpNo, SStream *O) {
2089
19
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, OpNo));
2090
  // assert(MI->getOpcode() == AArch64::DSBnXS);
2091
2092
19
  const char *Name = NULL;
2093
19
  const DBnXS *DB = lookupDBnXSByEncoding(Val);
2094
19
  Name = DB ? DB->Name : NULL;
2095
2096
19
  if (Name) {
2097
19
    SStream_concat0(O, Name);
2098
2099
19
    if (MI->csh->detail) {
2100
19
#ifndef CAPSTONE_DIET
2101
19
      uint8_t access;
2102
2103
19
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2104
19
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2105
19
      MI->ac_idx++;
2106
19
#endif
2107
19
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_BARRIER;
2108
19
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].barrier = Val;
2109
19
      MI->flat_insn->detail->arm64.op_count++;
2110
19
    }
2111
19
  }
2112
0
  else {
2113
0
    printUInt32Bang(O, Val);
2114
2115
0
    if (MI->csh->detail) {
2116
0
#ifndef CAPSTONE_DIET
2117
0
      uint8_t access;
2118
2119
0
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2120
0
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2121
0
      MI->ac_idx++;
2122
0
#endif
2123
0
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2124
0
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
2125
0
      MI->flat_insn->detail->arm64.op_count++;
2126
0
    }
2127
0
  }
2128
19
}
2129
2130
static void printMRSSystemRegister(MCInst *MI, unsigned OpNum, SStream *O)
2131
2.39k
{
2132
2.39k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2133
2.39k
  const SysReg *Reg = lookupSysRegByEncoding(Val);
2134
2135
  // Horrible hack for the one register that has identical encodings but
2136
  // different names in MSR and MRS. Because of this, one of MRS and MSR is
2137
  // going to get the wrong entry
2138
2.39k
  if (Val == ARM64_SYSREG_DBGDTRRX_EL0) {
2139
26
    SStream_concat0(O, "dbgdtrrx_el0");
2140
2141
26
    if (MI->csh->detail) {
2142
26
#ifndef CAPSTONE_DIET
2143
26
      uint8_t access;
2144
2145
26
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2146
26
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2147
26
      MI->ac_idx++;
2148
26
#endif
2149
2150
26
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2151
26
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2152
26
      MI->flat_insn->detail->arm64.op_count++;
2153
26
    }
2154
2155
26
    return;
2156
26
  }
2157
2158
  // Another hack for a register which has an alternative name which is not an alias,
2159
  // and is not in the Armv9-A documentation.
2160
2.36k
  if( Val == ARM64_SYSREG_VSCTLR_EL2){
2161
35
    SStream_concat0(O, "ttbr0_el2");
2162
2163
35
    if (MI->csh->detail) {
2164
35
#ifndef CAPSTONE_DIET
2165
35
      uint8_t access;
2166
2167
35
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2168
35
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2169
35
      MI->ac_idx++;
2170
35
#endif
2171
2172
35
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2173
35
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2174
35
      MI->flat_insn->detail->arm64.op_count++;
2175
35
    }
2176
2177
35
    return;
2178
35
  }
2179
2180
  // if (Reg && Reg->Readable && Reg->haveFeatures(STI.getFeatureBits()))
2181
2.33k
  if (Reg && Reg->Readable) {
2182
268
    SStream_concat0(O, Reg->Name);
2183
2184
268
    if (MI->csh->detail) {
2185
268
#ifndef CAPSTONE_DIET
2186
268
      uint8_t access;
2187
2188
268
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2189
268
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2190
268
      MI->ac_idx++;
2191
268
#endif
2192
2193
268
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2194
268
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Reg->Encoding;
2195
268
      MI->flat_insn->detail->arm64.op_count++;
2196
268
    }
2197
2.06k
  } else {
2198
2.06k
    char result[128];
2199
2200
2.06k
    AArch64SysReg_genericRegisterString(Val, result);
2201
2.06k
    SStream_concat0(O, result);
2202
2203
2.06k
    if (MI->csh->detail) {
2204
2.06k
#ifndef CAPSTONE_DIET
2205
2.06k
      uint8_t access;
2206
2.06k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2207
2.06k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2208
2.06k
      MI->ac_idx++;
2209
2.06k
#endif
2210
2.06k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG_MRS;
2211
2.06k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Val;
2212
2.06k
      MI->flat_insn->detail->arm64.op_count++;
2213
2.06k
    }
2214
2.06k
  }
2215
2.33k
}
2216
2217
static void printMSRSystemRegister(MCInst *MI, unsigned OpNum, SStream *O)
2218
3.73k
{
2219
3.73k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2220
3.73k
  const SysReg *Reg = lookupSysRegByEncoding(Val);
2221
2222
  // Horrible hack for the one register that has identical encodings but
2223
  // different names in MSR and MRS. Because of this, one of MRS and MSR is
2224
  // going to get the wrong entry
2225
3.73k
  if (Val == ARM64_SYSREG_DBGDTRTX_EL0) {
2226
34
    SStream_concat0(O, "dbgdtrtx_el0");
2227
2228
34
    if (MI->csh->detail) {
2229
34
#ifndef CAPSTONE_DIET
2230
34
      uint8_t access;
2231
2232
34
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2233
34
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2234
34
      MI->ac_idx++;
2235
34
#endif
2236
2237
34
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2238
34
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2239
34
      MI->flat_insn->detail->arm64.op_count++;
2240
34
    }
2241
2242
34
    return;
2243
34
  }
2244
2245
  // Another hack for a register which has an alternative name which is not an alias,
2246
  // and is not in the Armv9-A documentation.
2247
3.70k
  if( Val == ARM64_SYSREG_VSCTLR_EL2){
2248
376
    SStream_concat0(O, "ttbr0_el2");
2249
2250
376
    if (MI->csh->detail) {
2251
376
#ifndef CAPSTONE_DIET
2252
376
      uint8_t access;
2253
2254
376
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2255
376
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2256
376
      MI->ac_idx++;
2257
376
#endif
2258
2259
376
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2260
376
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2261
376
      MI->flat_insn->detail->arm64.op_count++;
2262
376
    }
2263
2264
376
    return;
2265
376
  }
2266
2267
  // if (Reg && Reg->Writeable && Reg->haveFeatures(STI.getFeatureBits()))
2268
3.32k
  if (Reg && Reg->Writeable) {
2269
259
    SStream_concat0(O, Reg->Name);
2270
2271
259
    if (MI->csh->detail) {
2272
259
#ifndef CAPSTONE_DIET
2273
259
      uint8_t access;
2274
2275
259
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2276
259
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2277
259
      MI->ac_idx++;
2278
259
#endif
2279
2280
259
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2281
259
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Reg->Encoding;
2282
259
      MI->flat_insn->detail->arm64.op_count++;
2283
259
    }
2284
3.06k
  } else {
2285
3.06k
    char result[128];
2286
2287
3.06k
    AArch64SysReg_genericRegisterString(Val, result);
2288
3.06k
    SStream_concat0(O, result);
2289
2290
3.06k
    if (MI->csh->detail) {
2291
3.06k
#ifndef CAPSTONE_DIET
2292
3.06k
      uint8_t access;
2293
3.06k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2294
3.06k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2295
3.06k
      MI->ac_idx++;
2296
3.06k
#endif
2297
3.06k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG_MRS;
2298
3.06k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Val;
2299
3.06k
      MI->flat_insn->detail->arm64.op_count++;
2300
3.06k
    }
2301
3.06k
  }
2302
3.32k
}
2303
2304
static void printSystemPStateField(MCInst *MI, unsigned OpNum, SStream *O)
2305
431
{
2306
431
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2307
2308
431
  const PState *PState = lookupPStateByEncoding(Val);
2309
2310
431
  if (PState) {
2311
431
    SStream_concat0(O, PState->Name);
2312
2313
431
    if (MI->csh->detail) {
2314
431
#ifndef CAPSTONE_DIET
2315
431
      uint8_t access;
2316
431
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2317
431
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2318
431
      MI->ac_idx++;
2319
431
#endif
2320
431
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_PSTATE;
2321
431
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].pstate = Val;
2322
431
      MI->flat_insn->detail->arm64.op_count++;
2323
431
    }
2324
431
  } else {
2325
0
    printUInt32Bang(O, Val);
2326
2327
0
    if (MI->csh->detail) {
2328
0
#ifndef CAPSTONE_DIET
2329
0
      unsigned char access;
2330
2331
0
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2332
0
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2333
0
      MI->ac_idx++;
2334
0
#endif
2335
2336
0
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2337
0
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
2338
0
      MI->flat_insn->detail->arm64.op_count++;
2339
0
    }
2340
0
  }
2341
431
}
2342
2343
static void printSIMDType10Operand(MCInst *MI, unsigned OpNum, SStream *O)
2344
968
{
2345
968
  uint8_t RawVal = (uint8_t)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2346
968
  uint64_t Val = AArch64_AM_decodeAdvSIMDModImmType10(RawVal);
2347
2348
968
  SStream_concat(O, "#%#016llx", Val);
2349
2350
968
  if (MI->csh->detail) {
2351
968
#ifndef CAPSTONE_DIET
2352
968
    unsigned char access;
2353
2354
968
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2355
968
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2356
968
    MI->ac_idx++;
2357
968
#endif
2358
968
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2359
968
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
2360
968
    MI->flat_insn->detail->arm64.op_count++;
2361
968
  }
2362
968
}
2363
2364
static void printComplexRotationOp(MCInst *MI, unsigned OpNum, SStream *O, int64_t Angle, int64_t Remainder)
2365
2.55k
{
2366
2.55k
  unsigned int Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2367
2.55k
  printInt64Bang(O, (Val * Angle) + Remainder);
2368
2.55k
  op_addImm(MI, (Val * Angle) + Remainder);
2369
2.55k
}
2370
2371
static void printSVCROp(MCInst *MI, unsigned OpNum, SStream *O)
2372
0
{
2373
0
  MCOperand *MO = MCInst_getOperand(MI, OpNum);
2374
    // assert(MCOperand_isImm(MO) && "Unexpected operand type!");
2375
0
    unsigned svcrop = MCOperand_getImm(MO);
2376
0
  const SVCR *svcr = lookupSVCRByEncoding(svcrop);
2377
    // assert(svcr && "Unexpected SVCR operand!");
2378
0
  SStream_concat0(O, svcr->Name);
2379
2380
0
  if (MI->csh->detail) {
2381
0
#ifndef CAPSTONE_DIET
2382
0
    uint8_t access;
2383
2384
0
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2385
0
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2386
0
    MI->ac_idx++;
2387
0
#endif
2388
2389
0
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SVCR;
2390
0
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = (unsigned)ARM64_SYSREG_SVCR;
2391
0
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].svcr = svcr->Encoding;
2392
0
    MI->flat_insn->detail->arm64.op_count++;
2393
0
  }
2394
0
}
2395
2396
static void printMatrix(MCInst *MI, unsigned OpNum, SStream *O, int EltSize)
2397
184
{
2398
184
  MCOperand *RegOp = MCInst_getOperand(MI, OpNum);
2399
    // assert(MCOperand_isReg(RegOp) && "Unexpected operand type!");
2400
184
  unsigned Reg = MCOperand_getReg(RegOp);
2401
2402
184
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2403
184
  const char *sizeStr = "";
2404
184
    switch (EltSize) {
2405
184
    case 0:
2406
184
    sizeStr = "";
2407
184
      break;
2408
0
    case 8:
2409
0
      sizeStr = ".b";
2410
0
      break;
2411
0
    case 16:
2412
0
      sizeStr = ".h";
2413
0
      break;
2414
0
    case 32:
2415
0
      sizeStr = ".s";
2416
0
      break;
2417
0
    case 64:
2418
0
      sizeStr = ".d";
2419
0
      break;
2420
0
    case 128:
2421
0
      sizeStr = ".q";
2422
0
      break;
2423
0
    default:
2424
0
    break;
2425
    //   llvm_unreachable("Unsupported element size");
2426
184
    }
2427
184
  SStream_concat0(O, sizeStr);
2428
2429
184
  if (MI->csh->detail) {
2430
184
#ifndef CAPSTONE_DIET
2431
184
    uint8_t access;
2432
2433
184
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2434
184
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2435
184
    MI->ac_idx++;
2436
184
#endif
2437
2438
184
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2439
184
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2440
184
    MI->flat_insn->detail->arm64.op_count++;
2441
184
  }
2442
184
}
2443
2444
static void printMatrixIndex(MCInst *MI, unsigned OpNum, SStream *O)
2445
7.21k
{
2446
7.21k
  int64_t imm = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2447
7.21k
  printInt64(O, imm);
2448
2449
7.21k
  if (MI->csh->detail) {
2450
7.21k
    if (MI->csh->doing_SME_Index) {
2451
      // Access op_count-1 as We want to add info to previous operand, not create a new one
2452
7.21k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count-1].sme_index.disp = imm;
2453
7.21k
    }
2454
7.21k
  }
2455
7.21k
}
2456
2457
static void printMatrixTile(MCInst *MI, unsigned OpNum, SStream *O)
2458
1.65k
{
2459
1.65k
  MCOperand *RegOp = MCInst_getOperand(MI, OpNum);
2460
    // assert(MCOperand_isReg(RegOp) && "Unexpected operand type!");
2461
1.65k
  unsigned Reg = MCOperand_getReg(RegOp);
2462
1.65k
    SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2463
2464
1.65k
  if (MI->csh->detail) {
2465
1.65k
#ifndef CAPSTONE_DIET
2466
1.65k
    uint8_t access;
2467
2468
1.65k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2469
1.65k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2470
1.65k
    MI->ac_idx++;
2471
1.65k
#endif
2472
2473
1.65k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2474
1.65k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2475
1.65k
    MI->flat_insn->detail->arm64.op_count++;
2476
1.65k
  }
2477
1.65k
}
2478
2479
static void printMatrixTileVector(MCInst *MI, unsigned OpNum, SStream *O, bool IsVertical)
2480
5.43k
{
2481
5.43k
  MCOperand *RegOp = MCInst_getOperand(MI, OpNum);
2482
    // assert(MCOperand_isReg(RegOp) && "Unexpected operand type!");
2483
5.43k
  unsigned Reg = MCOperand_getReg(RegOp);
2484
5.43k
#ifndef CAPSTONE_DIET
2485
5.43k
  const char *RegName = getRegisterName(Reg, AArch64_NoRegAltName);
2486
2487
5.43k
  const size_t strLn = strlen(RegName);
2488
  // +2 for extra chars, + 1 for null char \0
2489
5.43k
  char *RegNameNew = cs_mem_malloc(sizeof(char) * (strLn + 2 + 1));
2490
5.43k
  int index = 0, i;
2491
43.5k
  for (i = 0; i < (strLn + 2); i++){
2492
38.1k
    if(RegName[i] != '.'){
2493
32.7k
      RegNameNew[index] = RegName[i];
2494
32.7k
      index++;
2495
32.7k
    }
2496
5.43k
    else{
2497
5.43k
      RegNameNew[index] = IsVertical ? 'v' : 'h';
2498
5.43k
      RegNameNew[index + 1] = '.';
2499
5.43k
      index += 2;
2500
5.43k
    }
2501
38.1k
  }
2502
5.43k
  SStream_concat0(O, RegNameNew);
2503
5.43k
#endif
2504
2505
5.43k
  if (MI->csh->detail) {
2506
5.43k
#ifndef CAPSTONE_DIET
2507
5.43k
    uint8_t access;
2508
2509
5.43k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2510
5.43k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2511
5.43k
    MI->ac_idx++;
2512
5.43k
#endif
2513
2514
5.43k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2515
5.43k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2516
5.43k
    MI->flat_insn->detail->arm64.op_count++;
2517
5.43k
  }
2518
5.43k
#ifndef CAPSTONE_DIET
2519
5.43k
  cs_mem_free(RegNameNew);
2520
5.43k
#endif
2521
5.43k
}
2522
2523
static const unsigned MatrixZADRegisterTable[] = {
2524
  AArch64_ZAD0, AArch64_ZAD1, AArch64_ZAD2, AArch64_ZAD3,
2525
  AArch64_ZAD4, AArch64_ZAD5, AArch64_ZAD6, AArch64_ZAD7
2526
};
2527
2528
436
static void printMatrixTileList(MCInst *MI, unsigned OpNum, SStream *O){
2529
436
  unsigned MaxRegs = 8;
2530
436
  unsigned RegMask = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2531
2532
436
  unsigned NumRegs = 0, I;
2533
3.92k
  for (I = 0; I < MaxRegs; ++I)
2534
3.48k
    if ((RegMask & (1 << I)) != 0)
2535
997
      ++NumRegs;
2536
2537
436
  SStream_concat0(O, "{");
2538
436
  unsigned Printed = 0, J;
2539
3.92k
  for (J = 0; J < MaxRegs; ++J) {
2540
3.48k
    unsigned Reg = RegMask & (1 << J);
2541
3.48k
    if (Reg == 0)
2542
2.49k
      continue;
2543
997
    SStream_concat0(O, getRegisterName(MatrixZADRegisterTable[J], AArch64_NoRegAltName));
2544
2545
997
    if (MI->csh->detail) {
2546
997
#ifndef CAPSTONE_DIET
2547
997
      uint8_t access;
2548
2549
997
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2550
997
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2551
997
      MI->ac_idx++;
2552
997
#endif
2553
2554
997
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2555
997
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MatrixZADRegisterTable[J];
2556
997
      MI->flat_insn->detail->arm64.op_count++;
2557
997
    }
2558
2559
997
    if (Printed + 1 != NumRegs)
2560
562
      SStream_concat0(O, ", ");
2561
997
    ++Printed;
2562
997
  }
2563
436
  SStream_concat0(O, "}");
2564
436
}
2565
2566
static void printSVEPattern(MCInst *MI, unsigned OpNum, SStream *O)
2567
3.59k
{
2568
3.59k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2569
2570
3.59k
  const SVEPREDPAT *Pat = lookupSVEPREDPATByEncoding(Val);
2571
3.59k
  if (Pat)
2572
3.03k
    SStream_concat0(O, Pat->Name);
2573
557
  else
2574
557
    printUInt32Bang(O, Val);
2575
3.59k
}
2576
2577
// default suffix = 0
2578
static void printSVERegOp(MCInst *MI, unsigned OpNum, SStream *O, char suffix)
2579
124k
{
2580
124k
  unsigned int Reg;
2581
2582
#if 0
2583
  switch (suffix) {
2584
    case 0:
2585
    case 'b':
2586
    case 'h':
2587
    case 's':
2588
    case 'd':
2589
    case 'q':
2590
      break;
2591
    default:
2592
      // llvm_unreachable("Invalid kind specifier.");
2593
  }
2594
#endif
2595
2596
124k
  Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
2597
2598
124k
  if (MI->csh->detail) {
2599
124k
#ifndef CAPSTONE_DIET
2600
124k
      uint8_t access;
2601
2602
124k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2603
124k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2604
124k
      MI->ac_idx++;
2605
124k
#endif
2606
124k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2607
124k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2608
124k
    MI->flat_insn->detail->arm64.op_count++;
2609
124k
  }
2610
2611
124k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2612
2613
124k
  if (suffix != '\0')
2614
82.1k
    SStream_concat(O, ".%c", suffix);
2615
124k
}
2616
2617
static void printImmSVE16(int16_t Val, SStream *O)
2618
573
{
2619
573
  printUInt32Bang(O, Val);
2620
573
}
2621
2622
static void printImmSVE32(int32_t Val, SStream *O)
2623
837
{
2624
837
  printUInt32Bang(O, Val);
2625
837
}
2626
2627
static void printImmSVE64(int64_t Val, SStream *O)
2628
1.90k
{
2629
1.90k
  printUInt64Bang(O, Val);
2630
1.90k
}
2631
2632
static void printImm8OptLsl32(MCInst *MI, unsigned OpNum, SStream *O)
2633
925
{
2634
925
  unsigned UnscaledVal = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2635
925
  unsigned Shift = MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1));
2636
925
  uint32_t Val;
2637
2638
  // assert(AArch64_AM::getShiftType(Shift) == AArch64_AM::LSL &&
2639
  //  "Unexepected shift type!");
2640
2641
  // #0 lsl #8 is never pretty printed
2642
925
  if ((UnscaledVal == 0) && (AArch64_AM_getShiftValue(Shift) != 0)) {
2643
88
    printUInt32Bang(O, UnscaledVal);
2644
88
    printShifter(MI, OpNum + 1, O);
2645
88
    return;
2646
88
  }
2647
2648
837
  Val = UnscaledVal * (1 << AArch64_AM_getShiftValue(Shift));
2649
837
  printImmSVE32(Val, O);
2650
837
}
2651
2652
static void printImm8OptLsl64(MCInst *MI, unsigned OpNum, SStream *O)
2653
890
{
2654
890
  unsigned UnscaledVal = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2655
890
  unsigned Shift = MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1));
2656
890
  uint64_t Val;
2657
2658
  // assert(AArch64_AM::getShiftType(Shift) == AArch64_AM::LSL &&
2659
  //  "Unexepected shift type!");
2660
2661
  // #0 lsl #8 is never pretty printed
2662
890
  if ((UnscaledVal == 0) && (AArch64_AM_getShiftValue(Shift) != 0)) {
2663
83
    printUInt32Bang(O, UnscaledVal);
2664
83
    printShifter(MI, OpNum + 1, O);
2665
83
    return;
2666
83
  }
2667
2668
807
  Val = UnscaledVal * (1 << AArch64_AM_getShiftValue(Shift));
2669
807
  printImmSVE64(Val, O);
2670
807
}
2671
2672
static void printSVELogicalImm16(MCInst *MI, unsigned OpNum, SStream *O)
2673
359
{
2674
359
  uint64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2675
359
  uint64_t PrintVal = AArch64_AM_decodeLogicalImmediate(Val, 64);
2676
2677
  // Prefer the default format for 16bit values, hex otherwise.
2678
359
  printImmSVE16(PrintVal, O);
2679
359
}
2680
2681
static void printSVELogicalImm32(MCInst *MI, unsigned OpNum, SStream *O)
2682
977
{
2683
977
  uint64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2684
977
  uint64_t PrintVal = AArch64_AM_decodeLogicalImmediate(Val, 64);
2685
2686
  // Prefer the default format for 16bit values, hex otherwise.
2687
977
  if ((uint16_t)PrintVal == (uint32_t)PrintVal)
2688
214
    printImmSVE16(PrintVal, O);
2689
763
  else
2690
763
    printUInt64Bang(O, PrintVal);
2691
977
}
2692
2693
static void printSVELogicalImm64(MCInst *MI, unsigned OpNum, SStream *O)
2694
1.09k
{
2695
1.09k
  uint64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2696
1.09k
  uint64_t PrintVal = AArch64_AM_decodeLogicalImmediate(Val, 64);
2697
2698
1.09k
  printImmSVE64(PrintVal, O);
2699
1.09k
}
2700
2701
static void printZPRasFPR(MCInst *MI, unsigned OpNum, SStream *O, int Width)
2702
2.20k
{
2703
2.20k
  unsigned int Base, Reg;
2704
2705
2.20k
  switch (Width) {
2706
0
    default: // llvm_unreachable("Unsupported width");
2707
223
    case 8:   Base = AArch64_B0; break;
2708
477
    case 16:  Base = AArch64_H0; break;
2709
931
    case 32:  Base = AArch64_S0; break;
2710
501
    case 64:  Base = AArch64_D0; break;
2711
68
    case 128: Base = AArch64_Q0; break;
2712
2.20k
  }
2713
2714
2.20k
  Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum)) - AArch64_Z0 + Base;
2715
2716
2.20k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2717
2718
2.20k
  if (MI->csh->detail) {
2719
2.20k
#ifndef CAPSTONE_DIET
2720
2.20k
    uint8_t access;
2721
2722
2.20k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2723
2.20k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2724
2.20k
    MI->ac_idx++;
2725
2.20k
#endif
2726
2.20k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2727
2.20k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2728
2.20k
    MI->flat_insn->detail->arm64.op_count++;
2729
2.20k
  }
2730
2.20k
}
2731
2732
static void printExactFPImm(MCInst *MI, unsigned OpNum, SStream *O, unsigned ImmIs0, unsigned ImmIs1)
2733
752
{
2734
752
  const ExactFPImm *Imm0Desc = lookupExactFPImmByEnum(ImmIs0);
2735
752
  const ExactFPImm *Imm1Desc = lookupExactFPImmByEnum(ImmIs1);
2736
752
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2737
2738
752
  SStream_concat0(O, Val ? Imm1Desc->Repr : Imm0Desc->Repr);
2739
752
}
2740
2741
static void printGPR64as32(MCInst *MI, unsigned OpNum, SStream *O)
2742
3.69k
{
2743
3.69k
  unsigned int Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
2744
2745
3.69k
  SStream_concat0(O, getRegisterName(getWRegFromXReg(Reg), AArch64_NoRegAltName));
2746
3.69k
}
2747
2748
static void printGPR64x8(MCInst *MI, unsigned OpNum, SStream *O) 
2749
524
{
2750
524
    unsigned int Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
2751
2752
524
    SStream_concat0(O, getRegisterName(MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_x8sub_0), AArch64_NoRegAltName));
2753
524
}
2754
2755
#define PRINT_ALIAS_INSTR
2756
#include "AArch64GenAsmWriter.inc"
2757
#include "AArch64GenRegisterName.inc"
2758
2759
void AArch64_post_printer(csh handle, cs_insn *flat_insn, char *insn_asm, MCInst *mci)
2760
285k
{
2761
285k
  if (((cs_struct *)handle)->detail != CS_OPT_ON)
2762
0
    return;
2763
2764
285k
  if (mci->csh->detail) {
2765
285k
    unsigned opcode = MCInst_getOpcode(mci);
2766
2767
285k
    switch (opcode) {
2768
228k
      default:
2769
228k
        break;
2770
228k
      case AArch64_LD1Fourv16b_POST:
2771
691
      case AArch64_LD1Fourv1d_POST:
2772
852
      case AArch64_LD1Fourv2d_POST:
2773
947
      case AArch64_LD1Fourv2s_POST:
2774
1.56k
      case AArch64_LD1Fourv4h_POST:
2775
2.11k
      case AArch64_LD1Fourv4s_POST:
2776
2.33k
      case AArch64_LD1Fourv8b_POST:
2777
2.47k
      case AArch64_LD1Fourv8h_POST:
2778
2.52k
      case AArch64_LD1Onev16b_POST:
2779
2.60k
      case AArch64_LD1Onev1d_POST:
2780
2.66k
      case AArch64_LD1Onev2d_POST:
2781
2.90k
      case AArch64_LD1Onev2s_POST:
2782
3.00k
      case AArch64_LD1Onev4h_POST:
2783
3.10k
      case AArch64_LD1Onev4s_POST:
2784
3.36k
      case AArch64_LD1Onev8b_POST:
2785
3.64k
      case AArch64_LD1Onev8h_POST:
2786
3.70k
      case AArch64_LD1Rv16b_POST:
2787
3.71k
      case AArch64_LD1Rv1d_POST:
2788
3.90k
      case AArch64_LD1Rv2d_POST:
2789
3.98k
      case AArch64_LD1Rv2s_POST:
2790
4.05k
      case AArch64_LD1Rv4h_POST:
2791
4.37k
      case AArch64_LD1Rv4s_POST:
2792
4.38k
      case AArch64_LD1Rv8b_POST:
2793
4.39k
      case AArch64_LD1Rv8h_POST:
2794
4.78k
      case AArch64_LD1Threev16b_POST:
2795
4.92k
      case AArch64_LD1Threev1d_POST:
2796
4.94k
      case AArch64_LD1Threev2d_POST:
2797
5.01k
      case AArch64_LD1Threev2s_POST:
2798
5.10k
      case AArch64_LD1Threev4h_POST:
2799
5.24k
      case AArch64_LD1Threev4s_POST:
2800
5.27k
      case AArch64_LD1Threev8b_POST:
2801
5.53k
      case AArch64_LD1Threev8h_POST:
2802
5.67k
      case AArch64_LD1Twov16b_POST:
2803
5.70k
      case AArch64_LD1Twov1d_POST:
2804
5.98k
      case AArch64_LD1Twov2d_POST:
2805
6.11k
      case AArch64_LD1Twov2s_POST:
2806
6.16k
      case AArch64_LD1Twov4h_POST:
2807
6.34k
      case AArch64_LD1Twov4s_POST:
2808
6.82k
      case AArch64_LD1Twov8b_POST:
2809
7.48k
      case AArch64_LD1Twov8h_POST:
2810
7.94k
      case AArch64_LD1i16_POST:
2811
9.29k
      case AArch64_LD1i32_POST:
2812
10.2k
      case AArch64_LD1i64_POST:
2813
10.6k
      case AArch64_LD1i8_POST:
2814
10.6k
      case AArch64_LD2Rv16b_POST:
2815
11.0k
      case AArch64_LD2Rv1d_POST:
2816
11.2k
      case AArch64_LD2Rv2d_POST:
2817
11.2k
      case AArch64_LD2Rv2s_POST:
2818
11.5k
      case AArch64_LD2Rv4h_POST:
2819
11.6k
      case AArch64_LD2Rv4s_POST:
2820
11.7k
      case AArch64_LD2Rv8b_POST:
2821
11.7k
      case AArch64_LD2Rv8h_POST:
2822
12.0k
      case AArch64_LD2Twov16b_POST:
2823
12.1k
      case AArch64_LD2Twov2d_POST:
2824
12.2k
      case AArch64_LD2Twov2s_POST:
2825
12.6k
      case AArch64_LD2Twov4h_POST:
2826
12.6k
      case AArch64_LD2Twov4s_POST:
2827
12.6k
      case AArch64_LD2Twov8b_POST:
2828
12.8k
      case AArch64_LD2Twov8h_POST:
2829
12.9k
      case AArch64_LD2i16_POST:
2830
13.2k
      case AArch64_LD2i32_POST:
2831
13.9k
      case AArch64_LD2i64_POST:
2832
15.4k
      case AArch64_LD2i8_POST:
2833
15.5k
      case AArch64_LD3Rv16b_POST:
2834
15.9k
      case AArch64_LD3Rv1d_POST:
2835
16.3k
      case AArch64_LD3Rv2d_POST:
2836
16.4k
      case AArch64_LD3Rv2s_POST:
2837
16.5k
      case AArch64_LD3Rv4h_POST:
2838
16.8k
      case AArch64_LD3Rv4s_POST:
2839
16.8k
      case AArch64_LD3Rv8b_POST:
2840
17.1k
      case AArch64_LD3Rv8h_POST:
2841
17.3k
      case AArch64_LD3Threev16b_POST:
2842
17.6k
      case AArch64_LD3Threev2d_POST:
2843
17.6k
      case AArch64_LD3Threev2s_POST:
2844
18.0k
      case AArch64_LD3Threev4h_POST:
2845
18.1k
      case AArch64_LD3Threev4s_POST:
2846
18.1k
      case AArch64_LD3Threev8b_POST:
2847
18.4k
      case AArch64_LD3Threev8h_POST:
2848
19.2k
      case AArch64_LD3i16_POST:
2849
20.3k
      case AArch64_LD3i32_POST:
2850
22.1k
      case AArch64_LD3i64_POST:
2851
22.6k
      case AArch64_LD3i8_POST:
2852
22.7k
      case AArch64_LD4Fourv16b_POST:
2853
22.7k
      case AArch64_LD4Fourv2d_POST:
2854
22.8k
      case AArch64_LD4Fourv2s_POST:
2855
22.9k
      case AArch64_LD4Fourv4h_POST:
2856
23.2k
      case AArch64_LD4Fourv4s_POST:
2857
23.3k
      case AArch64_LD4Fourv8b_POST:
2858
23.4k
      case AArch64_LD4Fourv8h_POST:
2859
23.4k
      case AArch64_LD4Rv16b_POST:
2860
24.4k
      case AArch64_LD4Rv1d_POST:
2861
24.7k
      case AArch64_LD4Rv2d_POST:
2862
25.3k
      case AArch64_LD4Rv2s_POST:
2863
25.4k
      case AArch64_LD4Rv4h_POST:
2864
26.0k
      case AArch64_LD4Rv4s_POST:
2865
26.0k
      case AArch64_LD4Rv8b_POST:
2866
26.4k
      case AArch64_LD4Rv8h_POST:
2867
26.6k
      case AArch64_LD4i16_POST:
2868
27.1k
      case AArch64_LD4i32_POST:
2869
27.8k
      case AArch64_LD4i64_POST:
2870
28.3k
      case AArch64_LD4i8_POST:
2871
28.3k
      case AArch64_LDRBBpost:
2872
28.3k
      case AArch64_LDRBpost:
2873
28.3k
      case AArch64_LDRDpost:
2874
28.5k
      case AArch64_LDRHHpost:
2875
28.5k
      case AArch64_LDRHpost:
2876
28.6k
      case AArch64_LDRQpost:
2877
28.6k
      case AArch64_LDPDpost:
2878
28.7k
      case AArch64_LDPQpost:
2879
28.8k
      case AArch64_LDPSWpost:
2880
28.9k
      case AArch64_LDPSpost:
2881
29.2k
      case AArch64_LDPWpost:
2882
29.3k
      case AArch64_LDPXpost:
2883
29.3k
      case AArch64_ST1Fourv16b_POST:
2884
29.5k
      case AArch64_ST1Fourv1d_POST:
2885
29.7k
      case AArch64_ST1Fourv2d_POST:
2886
29.8k
      case AArch64_ST1Fourv2s_POST:
2887
29.9k
      case AArch64_ST1Fourv4h_POST:
2888
30.0k
      case AArch64_ST1Fourv4s_POST:
2889
30.2k
      case AArch64_ST1Fourv8b_POST:
2890
31.5k
      case AArch64_ST1Fourv8h_POST:
2891
31.5k
      case AArch64_ST1Onev16b_POST:
2892
31.7k
      case AArch64_ST1Onev1d_POST:
2893
31.7k
      case AArch64_ST1Onev2d_POST:
2894
31.8k
      case AArch64_ST1Onev2s_POST:
2895
31.8k
      case AArch64_ST1Onev4h_POST:
2896
32.3k
      case AArch64_ST1Onev4s_POST:
2897
32.4k
      case AArch64_ST1Onev8b_POST:
2898
32.5k
      case AArch64_ST1Onev8h_POST:
2899
32.6k
      case AArch64_ST1Threev16b_POST:
2900
32.6k
      case AArch64_ST1Threev1d_POST:
2901
32.7k
      case AArch64_ST1Threev2d_POST:
2902
32.8k
      case AArch64_ST1Threev2s_POST:
2903
33.4k
      case AArch64_ST1Threev4h_POST:
2904
33.4k
      case AArch64_ST1Threev4s_POST:
2905
34.1k
      case AArch64_ST1Threev8b_POST:
2906
34.2k
      case AArch64_ST1Threev8h_POST:
2907
34.3k
      case AArch64_ST1Twov16b_POST:
2908
34.4k
      case AArch64_ST1Twov1d_POST:
2909
34.5k
      case AArch64_ST1Twov2d_POST:
2910
34.5k
      case AArch64_ST1Twov2s_POST:
2911
34.7k
      case AArch64_ST1Twov4h_POST:
2912
34.8k
      case AArch64_ST1Twov4s_POST:
2913
34.8k
      case AArch64_ST1Twov8b_POST:
2914
34.9k
      case AArch64_ST1Twov8h_POST:
2915
35.2k
      case AArch64_ST1i16_POST:
2916
35.4k
      case AArch64_ST1i32_POST:
2917
35.5k
      case AArch64_ST1i64_POST:
2918
35.8k
      case AArch64_ST1i8_POST:
2919
36.5k
      case AArch64_ST2GPostIndex:
2920
36.9k
      case AArch64_ST2Twov16b_POST:
2921
36.9k
      case AArch64_ST2Twov2d_POST:
2922
37.0k
      case AArch64_ST2Twov2s_POST:
2923
37.1k
      case AArch64_ST2Twov4h_POST:
2924
37.3k
      case AArch64_ST2Twov4s_POST:
2925
37.4k
      case AArch64_ST2Twov8b_POST:
2926
37.8k
      case AArch64_ST2Twov8h_POST:
2927
38.2k
      case AArch64_ST2i16_POST:
2928
38.3k
      case AArch64_ST2i32_POST:
2929
38.5k
      case AArch64_ST2i64_POST:
2930
38.9k
      case AArch64_ST2i8_POST:
2931
39.1k
      case AArch64_ST3Threev16b_POST:
2932
39.2k
      case AArch64_ST3Threev2d_POST:
2933
39.7k
      case AArch64_ST3Threev2s_POST:
2934
39.7k
      case AArch64_ST3Threev4h_POST:
2935
39.9k
      case AArch64_ST3Threev4s_POST:
2936
40.0k
      case AArch64_ST3Threev8b_POST:
2937
40.0k
      case AArch64_ST3Threev8h_POST:
2938
40.7k
      case AArch64_ST3i16_POST:
2939
41.2k
      case AArch64_ST3i32_POST:
2940
41.4k
      case AArch64_ST3i64_POST:
2941
41.6k
      case AArch64_ST3i8_POST:
2942
42.4k
      case AArch64_ST4Fourv16b_POST:
2943
42.4k
      case AArch64_ST4Fourv2d_POST:
2944
42.8k
      case AArch64_ST4Fourv2s_POST:
2945
42.9k
      case AArch64_ST4Fourv4h_POST:
2946
43.1k
      case AArch64_ST4Fourv4s_POST:
2947
43.4k
      case AArch64_ST4Fourv8b_POST:
2948
43.5k
      case AArch64_ST4Fourv8h_POST:
2949
43.5k
      case AArch64_ST4i16_POST:
2950
43.8k
      case AArch64_ST4i32_POST:
2951
43.9k
      case AArch64_ST4i64_POST:
2952
44.0k
      case AArch64_ST4i8_POST:
2953
44.4k
      case AArch64_STPDpost:
2954
44.5k
      case AArch64_STPQpost:
2955
44.7k
      case AArch64_STPSpost:
2956
44.9k
      case AArch64_STPWpost:
2957
45.3k
      case AArch64_STPXpost:
2958
45.4k
      case AArch64_STRBBpost:
2959
45.5k
      case AArch64_STRBpost:
2960
45.5k
      case AArch64_STRDpost:
2961
45.7k
      case AArch64_STRHHpost:
2962
45.9k
      case AArch64_STRHpost:
2963
46.2k
      case AArch64_STRQpost:
2964
46.3k
      case AArch64_STRSpost:
2965
46.3k
      case AArch64_STRWpost:
2966
46.3k
      case AArch64_STRXpost:
2967
46.4k
      case AArch64_STZ2GPostIndex:
2968
46.5k
      case AArch64_STZGPostIndex:
2969
46.6k
      case AArch64_STGPostIndex:
2970
46.6k
      case AArch64_STGPpost:
2971
47.1k
      case AArch64_LDRSBWpost:
2972
47.1k
      case AArch64_LDRSBXpost:
2973
47.3k
      case AArch64_LDRSHWpost:
2974
47.7k
      case AArch64_LDRSHXpost:
2975
48.0k
      case AArch64_LDRSWpost:
2976
48.0k
      case AArch64_LDRSpost:
2977
48.0k
      case AArch64_LDRWpost:
2978
48.1k
      case AArch64_LDRXpost:
2979
48.1k
        flat_insn->detail->arm64.writeback = true;
2980
48.1k
          flat_insn->detail->arm64.post_index = true;
2981
48.1k
        break;
2982
79
      case AArch64_LDRAAwriteback:
2983
412
      case AArch64_LDRABwriteback:
2984
693
      case AArch64_ST2GPreIndex:
2985
995
      case AArch64_LDPDpre:
2986
1.14k
      case AArch64_LDPQpre:
2987
1.28k
      case AArch64_LDPSWpre:
2988
1.45k
      case AArch64_LDPSpre:
2989
1.48k
      case AArch64_LDPWpre:
2990
1.98k
      case AArch64_LDPXpre:
2991
2.22k
      case AArch64_LDRBBpre:
2992
2.46k
      case AArch64_LDRBpre:
2993
2.51k
      case AArch64_LDRDpre:
2994
2.61k
      case AArch64_LDRHHpre:
2995
2.91k
      case AArch64_LDRHpre:
2996
2.99k
      case AArch64_LDRQpre:
2997
3.70k
      case AArch64_LDRSBWpre:
2998
3.79k
      case AArch64_LDRSBXpre:
2999
4.00k
      case AArch64_LDRSHWpre:
3000
4.07k
      case AArch64_LDRSHXpre:
3001
4.10k
      case AArch64_LDRSWpre:
3002
4.30k
      case AArch64_LDRSpre:
3003
4.40k
      case AArch64_LDRWpre:
3004
4.50k
      case AArch64_LDRXpre:
3005
4.68k
      case AArch64_STGPreIndex:
3006
4.77k
      case AArch64_STPDpre:
3007
5.27k
      case AArch64_STPQpre:
3008
5.29k
      case AArch64_STPSpre:
3009
5.36k
      case AArch64_STPWpre:
3010
5.67k
      case AArch64_STPXpre:
3011
5.80k
      case AArch64_STRBBpre:
3012
6.18k
      case AArch64_STRBpre:
3013
6.34k
      case AArch64_STRDpre:
3014
6.66k
      case AArch64_STRHHpre:
3015
6.77k
      case AArch64_STRHpre:
3016
6.94k
      case AArch64_STRQpre:
3017
7.17k
      case AArch64_STRSpre:
3018
7.25k
      case AArch64_STRWpre:
3019
7.52k
      case AArch64_STRXpre:
3020
7.85k
      case AArch64_STZ2GPreIndex:
3021
8.14k
      case AArch64_STZGPreIndex:
3022
8.14k
      case AArch64_STGPpre:
3023
        flat_insn->detail->arm64.writeback = true;
3024
8.14k
        break;
3025
285k
    }
3026
285k
  }
3027
285k
}
3028
3029
#endif