Coverage Report

Created: 2026-05-30 06:22

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
913k
{
56
913k
#ifndef CAPSTONE_DIET
57
913k
  const uint8_t *arr = AArch64_get_op_access(h, id);
58
59
913k
  if (arr[index] == CS_AC_IGNORE)
60
0
    return 0;
61
62
913k
  return arr[index];
63
#else
64
  return 0;
65
#endif
66
913k
}
67
68
static void op_addImm(MCInst *MI, int v)
69
2.37k
{
70
2.37k
  if (MI->csh->detail) {
71
2.37k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
72
2.37k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = v;
73
2.37k
    MI->flat_insn->detail->arm64.op_count++;
74
2.37k
  }
75
2.37k
}
76
77
static void set_sme_index(MCInst *MI, bool status)
78
8.23k
{
79
  // Doing SME Index operand
80
8.23k
  MI->csh->doing_SME_Index = status;
81
82
8.23k
  if (MI->csh->detail != CS_OPT_ON)
83
0
    return;
84
85
8.23k
  if (status) {
86
5.77k
    unsigned prevOpNum = MI->flat_insn->detail->arm64.op_count - 1; 
87
5.77k
    unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, prevOpNum));
88
    // Replace previous SME register operand with an OP_SME_INDEX operand
89
5.77k
    MI->flat_insn->detail->arm64.operands[prevOpNum].type = ARM64_OP_SME_INDEX;
90
5.77k
    MI->flat_insn->detail->arm64.operands[prevOpNum].sme_index.reg = Reg;
91
5.77k
    MI->flat_insn->detail->arm64.operands[prevOpNum].sme_index.base = ARM64_REG_INVALID;
92
5.77k
    MI->flat_insn->detail->arm64.operands[prevOpNum].sme_index.disp = 0;
93
5.77k
  }
94
8.23k
}
95
96
static void set_mem_access(MCInst *MI, bool status)
97
304k
{
98
  // If status == false, check if this is meant for SME_index
99
304k
  if(!status && MI->csh->doing_SME_Index) {
100
3.32k
    MI->csh->doing_SME_Index = status;
101
3.32k
    return;
102
3.32k
  }
103
104
  // Doing Memory Operation
105
301k
  MI->csh->doing_mem = status;
106
107
108
301k
  if (MI->csh->detail != CS_OPT_ON)
109
0
    return;
110
111
301k
  if (status) {
112
150k
#ifndef CAPSTONE_DIET
113
150k
    uint8_t access;
114
150k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
115
150k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
116
150k
    MI->ac_idx++;
117
150k
#endif
118
150k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_MEM;
119
150k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.base = ARM64_REG_INVALID;
120
150k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.index = ARM64_REG_INVALID;
121
150k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = 0;
122
150k
  } else {
123
    // done, create the next operand slot
124
150k
    MI->flat_insn->detail->arm64.op_count++;
125
150k
  }
126
301k
}
127
128
void AArch64_printInst(MCInst *MI, SStream *O, void *Info)
129
320k
{
130
  // Check for special encodings and print the canonical alias instead.
131
320k
  unsigned Opcode = MCInst_getOpcode(MI);
132
320k
  int LSB, Width;
133
320k
  char *mnem;
134
135
  // printf(">>> opcode = %u\n", MCInst_getOpcode(MI));
136
137
320k
  if (Opcode == AArch64_SYSxt && printSysAlias(MI, O))
138
1.75k
    return;
139
140
  // SBFM/UBFM should print to a nicer aliased form if possible.
141
318k
  if (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri ||
142
315k
      Opcode == AArch64_UBFMXri || Opcode == AArch64_UBFMWri) {
143
3.75k
    bool IsSigned = (Opcode == AArch64_SBFMXri || Opcode == AArch64_SBFMWri);
144
3.75k
    bool Is64Bit = (Opcode == AArch64_SBFMXri || Opcode == AArch64_UBFMXri);
145
146
3.75k
    MCOperand *Op0 = MCInst_getOperand(MI, 0);
147
3.75k
    MCOperand *Op1 = MCInst_getOperand(MI, 1);
148
3.75k
    MCOperand *Op2 = MCInst_getOperand(MI, 2);
149
3.75k
    MCOperand *Op3 = MCInst_getOperand(MI, 3);
150
151
3.75k
    if (MCOperand_isImm(Op2) && MCOperand_getImm(Op2) == 0 && MCOperand_isImm(Op3)) {
152
2.79k
      const char *AsmMnemonic = NULL;
153
154
2.79k
      switch (MCOperand_getImm(Op3)) {
155
564
        default:
156
564
          break;
157
158
594
        case 7:
159
594
          if (IsSigned)
160
483
            AsmMnemonic = "sxtb";
161
111
          else if (!Is64Bit)
162
41
            AsmMnemonic = "uxtb";
163
594
          break;
164
165
1.03k
        case 15:
166
1.03k
          if (IsSigned)
167
730
            AsmMnemonic = "sxth";
168
307
          else if (!Is64Bit)
169
269
            AsmMnemonic = "uxth";
170
1.03k
          break;
171
172
602
        case 31:
173
          // *xtw is only valid for signed 64-bit operations.
174
602
          if (Is64Bit && IsSigned)
175
357
            AsmMnemonic = "sxtw";
176
602
          break;
177
2.79k
      }
178
179
2.79k
      if (AsmMnemonic) {
180
1.88k
        SStream_concat(O, "%s\t%s, %s", AsmMnemonic,
181
1.88k
            getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
182
1.88k
            getRegisterName(getWRegFromXReg(MCOperand_getReg(Op1)), AArch64_NoRegAltName));
183
184
1.88k
        if (MI->csh->detail) {
185
1.88k
#ifndef CAPSTONE_DIET
186
1.88k
          uint8_t access;
187
1.88k
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
188
1.88k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
189
1.88k
          MI->ac_idx++;
190
1.88k
#endif
191
1.88k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
192
1.88k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
193
1.88k
          MI->flat_insn->detail->arm64.op_count++;
194
1.88k
#ifndef CAPSTONE_DIET
195
1.88k
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
196
1.88k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
197
1.88k
          MI->ac_idx++;
198
1.88k
#endif
199
1.88k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
200
1.88k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = getWRegFromXReg(MCOperand_getReg(Op1));
201
1.88k
          MI->flat_insn->detail->arm64.op_count++;
202
1.88k
        }
203
204
1.88k
        MCInst_setOpcodePub(MI, AArch64_map_insn(AsmMnemonic));
205
206
1.88k
        return;
207
1.88k
      }
208
2.79k
    }
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
1.87k
    if (MCOperand_isImm(Op2) && MCOperand_isImm(Op3)) {
214
1.87k
      const char *AsmMnemonic = NULL;
215
1.87k
      int shift = 0;
216
1.87k
      int immr = (int)MCOperand_getImm(Op2);
217
1.87k
      int imms = (int)MCOperand_getImm(Op3);
218
219
1.87k
      if (Opcode == AArch64_UBFMWri && imms != 0x1F && ((imms + 1) == immr)) {
220
120
        AsmMnemonic = "lsl";
221
120
        shift = 31 - imms;
222
1.75k
      } else if (Opcode == AArch64_UBFMXri && imms != 0x3f &&
223
324
          ((imms + 1 == immr))) {
224
57
        AsmMnemonic = "lsl";
225
57
        shift = 63 - imms;
226
1.70k
      } else if (Opcode == AArch64_UBFMWri && imms == 0x1f) {
227
174
        AsmMnemonic = "lsr";
228
174
        shift = immr;
229
1.52k
      } else if (Opcode == AArch64_UBFMXri && imms == 0x3f) {
230
43
        AsmMnemonic = "lsr";
231
43
        shift = immr;
232
1.48k
      } else if (Opcode == AArch64_SBFMWri && imms == 0x1f) {
233
8
        AsmMnemonic = "asr";
234
8
        shift = immr;
235
1.47k
      } else if (Opcode == AArch64_SBFMXri && imms == 0x3f) {
236
277
        AsmMnemonic = "asr";
237
277
        shift = immr;
238
277
      }
239
240
1.87k
      if (AsmMnemonic) {
241
679
        SStream_concat(O, "%s\t%s, %s, ", AsmMnemonic,
242
679
            getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
243
679
            getRegisterName(MCOperand_getReg(Op1), AArch64_NoRegAltName));
244
245
679
        printInt32Bang(O, shift);
246
247
679
        MCInst_setOpcodePub(MI, AArch64_map_insn(AsmMnemonic));
248
249
679
        if (MI->csh->detail) {
250
679
#ifndef CAPSTONE_DIET
251
679
          uint8_t access;
252
679
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
253
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
254
679
          MI->ac_idx++;
255
679
#endif
256
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
257
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
258
679
          MI->flat_insn->detail->arm64.op_count++;
259
679
#ifndef CAPSTONE_DIET
260
679
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
261
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
262
679
          MI->ac_idx++;
263
679
#endif
264
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
265
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op1);
266
679
          MI->flat_insn->detail->arm64.op_count++;
267
679
#ifndef CAPSTONE_DIET
268
679
          access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
269
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
270
679
          MI->ac_idx++;
271
679
#endif
272
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
273
679
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = shift;
274
679
          MI->flat_insn->detail->arm64.op_count++;
275
679
        }
276
277
679
        return;
278
679
      }
279
1.87k
    }
280
281
    // SBFIZ/UBFIZ aliases
282
1.19k
    if (MCOperand_getImm(Op2) > MCOperand_getImm(Op3)) {
283
598
      SStream_concat(O, "%s\t%s, %s, ", (IsSigned ? "sbfiz" : "ubfiz"),
284
598
          getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
285
598
          getRegisterName(MCOperand_getReg(Op1), AArch64_NoRegAltName));
286
287
598
      printInt32Bang(O, (int)((Is64Bit ? 64 : 32) - MCOperand_getImm(Op2)));
288
289
598
      SStream_concat0(O, ", ");
290
291
598
      printInt32Bang(O, (int)MCOperand_getImm(Op3) + 1);
292
293
598
      MCInst_setOpcodePub(MI, AArch64_map_insn(IsSigned ? "sbfiz" : "ubfiz"));
294
295
598
      if (MI->csh->detail) {
296
598
#ifndef CAPSTONE_DIET
297
598
        uint8_t access;
298
598
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
299
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
300
598
        MI->ac_idx++;
301
598
#endif
302
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
303
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
304
598
        MI->flat_insn->detail->arm64.op_count++;
305
598
#ifndef CAPSTONE_DIET
306
598
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
307
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
308
598
        MI->ac_idx++;
309
598
#endif
310
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
311
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op1);
312
598
        MI->flat_insn->detail->arm64.op_count++;
313
598
#ifndef CAPSTONE_DIET
314
598
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
315
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
316
598
        MI->ac_idx++;
317
598
#endif
318
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
319
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = (Is64Bit ? 64 : 32) - (int)MCOperand_getImm(Op2);
320
598
        MI->flat_insn->detail->arm64.op_count++;
321
598
#ifndef CAPSTONE_DIET
322
598
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
323
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
324
598
        MI->ac_idx++;
325
598
#endif
326
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
327
598
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op3) + 1;
328
598
        MI->flat_insn->detail->arm64.op_count++;
329
598
      }
330
331
598
      return;
332
598
    }
333
334
    // Otherwise SBFX/UBFX is the preferred form
335
600
    SStream_concat(O, "%s\t%s, %s, ", (IsSigned ? "sbfx" : "ubfx"),
336
600
        getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
337
600
        getRegisterName(MCOperand_getReg(Op1), AArch64_NoRegAltName));
338
339
600
    printInt32Bang(O, (int)MCOperand_getImm(Op2));
340
600
    SStream_concat0(O, ", ");
341
600
    printInt32Bang(O, (int)MCOperand_getImm(Op3) - (int)MCOperand_getImm(Op2) + 1);
342
343
600
    MCInst_setOpcodePub(MI, AArch64_map_insn(IsSigned ? "sbfx" : "ubfx"));
344
345
600
    if (MI->csh->detail) {
346
600
#ifndef CAPSTONE_DIET
347
600
      uint8_t access;
348
600
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
349
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
350
600
      MI->ac_idx++;
351
600
#endif
352
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
353
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
354
600
      MI->flat_insn->detail->arm64.op_count++;
355
600
#ifndef CAPSTONE_DIET
356
600
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
357
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
358
600
      MI->ac_idx++;
359
600
#endif
360
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
361
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op1);
362
600
      MI->flat_insn->detail->arm64.op_count++;
363
600
#ifndef CAPSTONE_DIET
364
600
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
365
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
366
600
      MI->ac_idx++;
367
600
#endif
368
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
369
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op2);
370
600
      MI->flat_insn->detail->arm64.op_count++;
371
600
#ifndef CAPSTONE_DIET
372
600
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
373
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
374
600
      MI->ac_idx++;
375
600
#endif
376
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
377
600
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op3) - MCOperand_getImm(Op2) + 1;
378
600
      MI->flat_insn->detail->arm64.op_count++;
379
600
    }
380
381
600
    return;
382
1.19k
  }
383
384
314k
  if (Opcode == AArch64_BFMXri || Opcode == AArch64_BFMWri) {
385
1.09k
    MCOperand *Op0 = MCInst_getOperand(MI, 0); // Op1 == Op0
386
1.09k
    MCOperand *Op2 = MCInst_getOperand(MI, 2);
387
1.09k
    int ImmR = (int)MCOperand_getImm(MCInst_getOperand(MI, 3));
388
1.09k
    int ImmS = (int)MCOperand_getImm(MCInst_getOperand(MI, 4));
389
390
1.09k
    if ((MCOperand_getReg(Op2) == AArch64_WZR || MCOperand_getReg(Op2) == AArch64_XZR) &&
391
647
        (ImmR == 0 || ImmS < ImmR)) {
392
      // BFC takes precedence over its entire range, sligtly differently to BFI.
393
452
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
394
452
      int LSB = (BitWidth - ImmR) % BitWidth;
395
452
      int Width = ImmS + 1;
396
397
452
      SStream_concat(O, "bfc\t%s, ",
398
452
          getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName));
399
400
452
      printInt32Bang(O, LSB);
401
452
      SStream_concat0(O, ", ");
402
452
      printInt32Bang(O, Width);
403
452
      MCInst_setOpcodePub(MI, AArch64_map_insn("bfc"));
404
405
452
      if (MI->csh->detail) {
406
452
#ifndef CAPSTONE_DIET
407
452
        uint8_t access;
408
452
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
409
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
410
452
        MI->ac_idx++;
411
452
#endif
412
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
413
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
414
452
        MI->flat_insn->detail->arm64.op_count++;
415
416
452
#ifndef CAPSTONE_DIET
417
452
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
418
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
419
452
        MI->ac_idx++;
420
452
#endif
421
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
422
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = LSB;
423
452
        MI->flat_insn->detail->arm64.op_count++;
424
452
#ifndef CAPSTONE_DIET
425
452
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
426
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
427
452
        MI->ac_idx++;
428
452
#endif
429
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
430
452
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Width;
431
452
        MI->flat_insn->detail->arm64.op_count++;
432
452
      }
433
434
452
      return;
435
639
    } else if (ImmS < ImmR) {
436
      // BFI alias
437
172
      int BitWidth = Opcode == AArch64_BFMXri ? 64 : 32;
438
172
      LSB = (BitWidth - ImmR) % BitWidth;
439
172
      Width = ImmS + 1;
440
441
172
      SStream_concat(O, "bfi\t%s, %s, ",
442
172
          getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
443
172
          getRegisterName(MCOperand_getReg(Op2), AArch64_NoRegAltName));
444
445
172
      printInt32Bang(O, LSB);
446
172
      SStream_concat0(O, ", ");
447
172
      printInt32Bang(O, Width);
448
449
172
      MCInst_setOpcodePub(MI, AArch64_map_insn("bfi"));
450
451
172
      if (MI->csh->detail) {
452
172
#ifndef CAPSTONE_DIET
453
172
        uint8_t access;
454
172
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
455
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
456
172
        MI->ac_idx++;
457
172
#endif
458
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
459
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
460
172
        MI->flat_insn->detail->arm64.op_count++;
461
172
#ifndef CAPSTONE_DIET
462
172
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
463
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
464
172
        MI->ac_idx++;
465
172
#endif
466
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
467
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op2);
468
172
        MI->flat_insn->detail->arm64.op_count++;
469
172
#ifndef CAPSTONE_DIET
470
172
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
471
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
472
172
        MI->ac_idx++;
473
172
#endif
474
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
475
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = LSB;
476
172
        MI->flat_insn->detail->arm64.op_count++;
477
172
#ifndef CAPSTONE_DIET
478
172
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
479
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
480
172
        MI->ac_idx++;
481
172
#endif
482
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
483
172
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Width;
484
172
        MI->flat_insn->detail->arm64.op_count++;
485
172
      }
486
487
172
      return;
488
172
    }
489
490
467
    LSB = ImmR;
491
467
    Width = ImmS - ImmR + 1;
492
    // Otherwise BFXIL the preferred form
493
467
    SStream_concat(O, "bfxil\t%s, %s, ",
494
467
        getRegisterName(MCOperand_getReg(Op0), AArch64_NoRegAltName),
495
467
        getRegisterName(MCOperand_getReg(Op2), AArch64_NoRegAltName));
496
497
467
    printInt32Bang(O, LSB);
498
467
    SStream_concat0(O, ", ");
499
467
    printInt32Bang(O, Width);
500
501
467
    MCInst_setOpcodePub(MI, AArch64_map_insn("bfxil"));
502
503
467
    if (MI->csh->detail) {
504
467
#ifndef CAPSTONE_DIET
505
467
      uint8_t access;
506
467
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
507
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
508
467
      MI->ac_idx++;
509
467
#endif
510
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
511
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op0);
512
467
      MI->flat_insn->detail->arm64.op_count++;
513
467
#ifndef CAPSTONE_DIET
514
467
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
515
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
516
467
      MI->ac_idx++;
517
467
#endif
518
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
519
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(Op2);
520
467
      MI->flat_insn->detail->arm64.op_count++;
521
467
#ifndef CAPSTONE_DIET
522
467
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
523
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
524
467
      MI->ac_idx++;
525
467
#endif
526
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
527
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = LSB;
528
467
      MI->flat_insn->detail->arm64.op_count++;
529
467
#ifndef CAPSTONE_DIET
530
467
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
531
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
532
467
      MI->ac_idx++;
533
467
#endif
534
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
535
467
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Width;
536
467
      MI->flat_insn->detail->arm64.op_count++;
537
467
    }
538
539
467
    return;
540
1.09k
  }
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
313k
  if ((Opcode == AArch64_MOVZXi || Opcode == AArch64_MOVZWi) &&
548
1.24k
      MCOperand_isImm(MCInst_getOperand(MI, 1)) && MCOperand_isImm(MCInst_getOperand(MI, 2))) {
549
1.24k
    int RegWidth = Opcode == AArch64_MOVZXi ? 64 : 32;
550
1.24k
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, 2));
551
1.24k
    uint64_t Value = (uint64_t)MCOperand_getImm(MCInst_getOperand(MI, 1)) << Shift;
552
553
1.24k
    if (isMOVZMovAlias(Value, Shift,
554
1.24k
          Opcode == AArch64_MOVZXi ? 64 : 32)) {
555
899
      SStream_concat(O, "mov\t%s, ", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 0)), AArch64_NoRegAltName));
556
557
899
      printInt64Bang(O, SignExtend64(Value, RegWidth));
558
559
899
      if (MI->csh->detail) {
560
899
#ifndef CAPSTONE_DIET
561
899
        uint8_t access;
562
899
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
563
899
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
564
899
        MI->ac_idx++;
565
899
#endif
566
899
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
567
899
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0));
568
899
        MI->flat_insn->detail->arm64.op_count++;
569
570
899
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
571
899
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = SignExtend64(Value, RegWidth);
572
899
        MI->flat_insn->detail->arm64.op_count++;
573
899
      }
574
575
899
      MCInst_setOpcodePub(MI, AArch64_map_insn("mov"));
576
577
899
      return;
578
899
    }
579
1.24k
  }
580
581
312k
  if ((Opcode == AArch64_MOVNXi || Opcode == AArch64_MOVNWi) &&
582
1.22k
      MCOperand_isImm(MCInst_getOperand(MI, 1)) && MCOperand_isImm(MCInst_getOperand(MI, 2))) {
583
1.22k
    int RegWidth = Opcode == AArch64_MOVNXi ? 64 : 32;
584
1.22k
    int Shift = MCOperand_getImm(MCInst_getOperand(MI, 2));
585
1.22k
    uint64_t Value = ~((uint64_t)MCOperand_getImm(MCInst_getOperand(MI, 1)) << Shift);
586
587
1.22k
    if (RegWidth == 32)
588
384
      Value = Value & 0xffffffff;
589
590
1.22k
    if (AArch64_AM_isMOVNMovAlias(Value, Shift, RegWidth)) {
591
1.03k
      SStream_concat(O, "mov\t%s, ", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 0)), AArch64_NoRegAltName));
592
593
1.03k
      printInt64Bang(O, SignExtend64(Value, RegWidth));
594
595
1.03k
      if (MI->csh->detail) {
596
1.03k
#ifndef CAPSTONE_DIET
597
1.03k
        uint8_t access;
598
1.03k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
599
1.03k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
600
1.03k
        MI->ac_idx++;
601
1.03k
#endif
602
1.03k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
603
1.03k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0));
604
1.03k
        MI->flat_insn->detail->arm64.op_count++;
605
606
1.03k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
607
1.03k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = SignExtend64(Value, RegWidth);
608
1.03k
        MI->flat_insn->detail->arm64.op_count++;
609
1.03k
      }
610
611
1.03k
      MCInst_setOpcodePub(MI, AArch64_map_insn("mov"));
612
613
1.03k
      return;
614
1.03k
    }
615
1.22k
  }
616
617
311k
  if ((Opcode == AArch64_ORRXri || Opcode == AArch64_ORRWri) &&
618
1.48k
      (MCOperand_getReg(MCInst_getOperand(MI, 1)) == AArch64_XZR ||
619
1.03k
       MCOperand_getReg(MCInst_getOperand(MI, 1)) == AArch64_WZR) &&
620
581
      MCOperand_isImm(MCInst_getOperand(MI, 2))) {
621
581
    int RegWidth = Opcode == AArch64_ORRXri ? 64 : 32;
622
581
    uint64_t Value = AArch64_AM_decodeLogicalImmediate(
623
581
        MCOperand_getImm(MCInst_getOperand(MI, 2)), RegWidth);
624
581
    SStream_concat(O, "mov\t%s, ", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 0)), AArch64_NoRegAltName));
625
626
581
    printInt64Bang(O, SignExtend64(Value, RegWidth));
627
628
581
    if (MI->csh->detail) {
629
581
#ifndef CAPSTONE_DIET
630
581
      uint8_t access;
631
581
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
632
581
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
633
581
      MI->ac_idx++;
634
581
#endif
635
581
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
636
581
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0));
637
581
      MI->flat_insn->detail->arm64.op_count++;
638
639
581
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
640
581
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = SignExtend64(Value, RegWidth);
641
581
      MI->flat_insn->detail->arm64.op_count++;
642
581
    }
643
644
581
    MCInst_setOpcodePub(MI, AArch64_map_insn("mov"));
645
646
581
    return;
647
581
  }
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
311k
  if (Opcode == AArch64_TSB) {
652
173
    SStream_concat0(O, "tsb\tcsync");
653
173
    MCInst_setOpcodePub(MI, AArch64_map_insn("tsb"));
654
173
    return;
655
173
  }
656
657
310k
  MI->MRI = Info;
658
659
310k
  mnem = printAliasInstr(MI, O, (MCRegisterInfo *)Info);
660
310k
  if (mnem) {
661
37.5k
    MCInst_setOpcodePub(MI, AArch64_map_insn(mnem));
662
37.5k
    cs_mem_free(mnem);
663
664
37.5k
    switch(MCInst_getOpcode(MI)) {
665
21.5k
      default: break;
666
21.5k
      case AArch64_LD1i8_POST:
667
448
        arm64_op_addImm(MI, 1);
668
448
        break;
669
142
      case AArch64_LD1i16_POST:
670
142
        arm64_op_addImm(MI, 2);
671
142
        break;
672
100
      case AArch64_LD1i32_POST:
673
100
        arm64_op_addImm(MI, 4);
674
100
        break;
675
128
      case AArch64_LD1Onev1d_POST:
676
290
      case AArch64_LD1Onev2s_POST:
677
339
      case AArch64_LD1Onev4h_POST:
678
425
      case AArch64_LD1Onev8b_POST:
679
1.52k
      case AArch64_LD1i64_POST:
680
1.52k
        arm64_op_addImm(MI, 8);
681
1.52k
        break;
682
103
      case AArch64_LD1Onev16b_POST:
683
391
      case AArch64_LD1Onev2d_POST:
684
525
      case AArch64_LD1Onev4s_POST:
685
694
      case AArch64_LD1Onev8h_POST:
686
844
      case AArch64_LD1Twov1d_POST:
687
869
      case AArch64_LD1Twov2s_POST:
688
1.02k
      case AArch64_LD1Twov4h_POST:
689
1.25k
      case AArch64_LD1Twov8b_POST:
690
1.25k
        arm64_op_addImm(MI, 16);
691
1.25k
        break;
692
33
      case AArch64_LD1Threev1d_POST:
693
124
      case AArch64_LD1Threev2s_POST:
694
162
      case AArch64_LD1Threev4h_POST:
695
493
      case AArch64_LD1Threev8b_POST:
696
493
        arm64_op_addImm(MI, 24);
697
493
        break;
698
164
      case AArch64_LD1Fourv1d_POST:
699
203
      case AArch64_LD1Fourv2s_POST:
700
285
      case AArch64_LD1Fourv4h_POST:
701
411
      case AArch64_LD1Fourv8b_POST:
702
631
      case AArch64_LD1Twov16b_POST:
703
872
      case AArch64_LD1Twov2d_POST:
704
1.05k
      case AArch64_LD1Twov4s_POST:
705
1.09k
      case AArch64_LD1Twov8h_POST:
706
1.09k
        arm64_op_addImm(MI, 32);
707
1.09k
        break;
708
253
      case AArch64_LD1Threev16b_POST:
709
341
      case AArch64_LD1Threev2d_POST:
710
725
      case AArch64_LD1Threev4s_POST:
711
894
      case AArch64_LD1Threev8h_POST:
712
894
         arm64_op_addImm(MI, 48);
713
894
         break;
714
73
      case AArch64_LD1Fourv16b_POST:
715
128
      case AArch64_LD1Fourv2d_POST:
716
445
      case AArch64_LD1Fourv4s_POST:
717
1.18k
      case AArch64_LD1Fourv8h_POST:
718
1.18k
        arm64_op_addImm(MI, 64);
719
1.18k
        break;
720
73
      case AArch64_UMOVvi64:
721
73
        arm64_op_addVectorArrSpecifier(MI, ARM64_VAS_1D);
722
73
        break;
723
269
      case AArch64_UMOVvi32:
724
269
        arm64_op_addVectorArrSpecifier(MI, ARM64_VAS_1S);
725
269
        break;
726
35
      case AArch64_INSvi8gpr:
727
231
      case AArch64_DUP_ZI_B:
728
390
      case AArch64_CPY_ZPmI_B:
729
634
      case AArch64_CPY_ZPzI_B:
730
718
      case AArch64_CPY_ZPmV_B:
731
950
      case AArch64_CPY_ZPmR_B:
732
1.07k
      case AArch64_DUP_ZR_B:
733
1.07k
        if (MI->csh->detail) {
734
1.07k
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
735
1.07k
        }
736
1.07k
        break;
737
51
      case AArch64_INSvi16gpr:
738
119
      case AArch64_DUP_ZI_H:
739
221
      case AArch64_CPY_ZPmI_H:
740
849
      case AArch64_CPY_ZPzI_H:
741
1.06k
      case AArch64_CPY_ZPmV_H:
742
1.12k
      case AArch64_CPY_ZPmR_H:
743
1.23k
      case AArch64_DUP_ZR_H:
744
1.29k
      case AArch64_FCPY_ZPmI_H:
745
1.51k
      case AArch64_FDUP_ZI_H:
746
1.51k
        if (MI->csh->detail) {
747
1.51k
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
748
1.51k
        }
749
1.51k
        break;
750
59
      case AArch64_INSvi32gpr:
751
127
      case AArch64_DUP_ZI_S:
752
447
      case AArch64_CPY_ZPmI_S:
753
520
      case AArch64_CPY_ZPzI_S:
754
562
      case AArch64_CPY_ZPmV_S:
755
665
      case AArch64_CPY_ZPmR_S:
756
737
      case AArch64_DUP_ZR_S:
757
750
      case AArch64_FCPY_ZPmI_S:
758
812
      case AArch64_FDUP_ZI_S:
759
812
        if (MI->csh->detail) {
760
812
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
761
812
        }
762
812
        break;
763
52
      case AArch64_INSvi64gpr:
764
129
      case AArch64_DUP_ZI_D:
765
230
      case AArch64_CPY_ZPmI_D:
766
505
      case AArch64_CPY_ZPzI_D:
767
520
      case AArch64_CPY_ZPmV_D:
768
621
      case AArch64_CPY_ZPmR_D:
769
723
      case AArch64_DUP_ZR_D:
770
776
      case AArch64_FCPY_ZPmI_D:
771
853
      case AArch64_FDUP_ZI_D:
772
853
        if (MI->csh->detail) {
773
853
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
774
853
        }
775
853
        break;
776
125
      case AArch64_INSvi8lane:
777
327
      case AArch64_ORR_PPzPP:
778
407
      case AArch64_ORRS_PPzPP:
779
407
        if (MI->csh->detail) {
780
407
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
781
407
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1B;
782
407
        }
783
407
        break;
784
117
      case AArch64_INSvi16lane:
785
117
        if (MI->csh->detail) {
786
117
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
787
117
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1H;
788
117
        }
789
117
         break;
790
245
      case AArch64_INSvi32lane:
791
245
        if (MI->csh->detail) {
792
245
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
793
245
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1S;
794
245
        }
795
245
        break;
796
100
      case AArch64_INSvi64lane:
797
171
      case AArch64_ORR_ZZZ:
798
171
        if (MI->csh->detail) {
799
171
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
800
171
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1D;
801
171
        }
802
171
        break;
803
55
      case AArch64_ORRv16i8:
804
139
      case AArch64_NOTv16i8:
805
139
        if (MI->csh->detail) {
806
139
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_16B;
807
139
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_16B;
808
139
        }
809
139
        break;
810
37
      case AArch64_ORRv8i8:
811
72
      case AArch64_NOTv8i8:
812
72
        if (MI->csh->detail) {
813
72
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_8B;
814
72
          MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_8B;
815
72
        }
816
72
        break;
817
202
      case AArch64_AND_PPzPP:
818
295
      case AArch64_ANDS_PPzPP:
819
330
      case AArch64_EOR_PPzPP:
820
361
      case AArch64_EORS_PPzPP:
821
551
      case AArch64_SEL_PPPP:
822
1.78k
      case AArch64_SEL_ZPZZ_B:
823
1.78k
        if (MI->csh->detail) {
824
1.78k
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
825
1.78k
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1B;
826
1.78k
        }
827
1.78k
        break;
828
5
      case AArch64_SEL_ZPZZ_D:
829
5
        if (MI->csh->detail) {
830
5
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
831
5
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1D;
832
5
        }
833
5
        break;
834
166
      case AArch64_SEL_ZPZZ_H:
835
166
        if (MI->csh->detail) {
836
166
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
837
166
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1H;
838
166
        }
839
166
        break;
840
333
      case AArch64_SEL_ZPZZ_S:
841
333
        if (MI->csh->detail) {
842
333
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
843
333
          MI->flat_insn->detail->arm64.operands[2].vas = ARM64_VAS_1S;
844
333
        }
845
333
        break;
846
166
      case AArch64_DUP_ZZI_B:
847
166
        if (MI->csh->detail) {
848
166
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1B;
849
166
          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
166
          } else {
852
166
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1B;
853
166
          }
854
166
        }
855
166
        break;
856
151
      case AArch64_DUP_ZZI_D:
857
151
        if (MI->csh->detail) {
858
151
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1D;
859
151
          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
151
          } else {
862
151
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1D;
863
151
          }
864
151
        }
865
151
        break;
866
38
      case AArch64_DUP_ZZI_H:
867
38
        if (MI->csh->detail) {
868
38
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1H;
869
38
          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
38
          } else {
872
38
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1H;
873
38
          }
874
38
        }
875
38
        break;
876
74
      case AArch64_DUP_ZZI_Q:
877
74
        if (MI->csh->detail) {
878
74
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1Q;
879
74
          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
74
          } else {
882
74
            MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1Q;
883
74
          }
884
74
         }
885
74
         break;
886
108
      case AArch64_DUP_ZZI_S:
887
108
        if (MI->csh->detail) {
888
108
          MI->flat_insn->detail->arm64.operands[0].vas = ARM64_VAS_1S;
889
108
          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
108
          } else {
892
108
             MI->flat_insn->detail->arm64.operands[1].vas = ARM64_VAS_1S;
893
108
          }
894
108
        }
895
108
        break;
896
      // Hacky detail filling of SMSTART and SMSTOP alias'
897
271
      case AArch64_MSRpstatesvcrImm1:{
898
271
        if(MI->csh->detail){
899
271
          MI->flat_insn->detail->arm64.op_count = 2;
900
271
#ifndef CAPSTONE_DIET
901
271
          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
271
          MI->ac_idx++;
903
271
          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
271
          MI->ac_idx++;
905
271
#endif
906
271
          MI->flat_insn->detail->arm64.operands[0].type = ARM64_OP_SVCR;
907
271
          MI->flat_insn->detail->arm64.operands[0].sys = (unsigned)ARM64_SYSREG_SVCR;
908
271
          MI->flat_insn->detail->arm64.operands[0].svcr = lookupSVCRByEncoding(MCOperand_getImm(MCInst_getOperand(MI, 0)))->Encoding;
909
271
          MI->flat_insn->detail->arm64.operands[1].type = ARM64_OP_IMM;
910
271
          MI->flat_insn->detail->arm64.operands[1].imm = MCOperand_getImm(MCInst_getOperand(MI, 1));
911
271
        }
912
271
        break;
913
551
      }
914
37.5k
    }
915
273k
  } else {
916
273k
    printInstruction(MI, O);
917
273k
  }
918
310k
}
919
920
static bool printSysAlias(MCInst *MI, SStream *O)
921
4.22k
{
922
  // unsigned Opcode = MCInst_getOpcode(MI);
923
  //assert(Opcode == AArch64_SYSxt && "Invalid opcode for SYS alias!");
924
925
4.22k
  const char *Ins;
926
4.22k
  uint16_t Encoding;
927
4.22k
  bool NeedsReg;
928
4.22k
  char Name[64];
929
4.22k
  MCOperand *Op1 = MCInst_getOperand(MI, 0);
930
4.22k
  MCOperand *Cn = MCInst_getOperand(MI, 1);
931
4.22k
  MCOperand *Cm = MCInst_getOperand(MI, 2);
932
4.22k
  MCOperand *Op2 = MCInst_getOperand(MI, 3);
933
934
4.22k
  unsigned Op1Val = (unsigned)MCOperand_getImm(Op1);
935
4.22k
  unsigned CnVal = (unsigned)MCOperand_getImm(Cn);
936
4.22k
  unsigned CmVal = (unsigned)MCOperand_getImm(Cm);
937
4.22k
  unsigned Op2Val = (unsigned)MCOperand_getImm(Op2);
938
939
4.22k
  Encoding = Op2Val;
940
4.22k
  Encoding |= CmVal << 3;
941
4.22k
  Encoding |= CnVal << 7;
942
4.22k
  Encoding |= Op1Val << 11;
943
944
4.22k
  if (CnVal == 7) {
945
3.52k
    switch (CmVal) {
946
53
      default:
947
53
        return false;
948
949
      // IC aliases
950
679
      case 1: case 5: {
951
679
        const IC *IC = lookupICByEncoding(Encoding);
952
        // if (!IC || !IC->haveFeatures(STI.getFeatureBits()))
953
679
        if (!IC)
954
142
          return false;
955
956
537
        NeedsReg = IC->NeedsReg;
957
537
        Ins = "ic";
958
537
        strncpy(Name, IC->Name, sizeof(Name) - 1);
959
537
      }
960
0
      break;
961
962
      // DC aliases
963
2.05k
      case 4: case 6: case 10: case 11: case 12: case 14: {
964
2.05k
        const DC *DC = lookupDCByEncoding(Encoding);
965
        // if (!DC || !DC->haveFeatures(STI.getFeatureBits()))
966
2.05k
        if (!DC)
967
1.60k
          return false;
968
969
449
        NeedsReg = true;
970
449
        Ins = "dc";
971
449
        strncpy(Name, DC->Name, sizeof(Name) - 1);
972
449
      }
973
0
      break;
974
975
      // AT aliases
976
740
      case 8: case 9: {
977
740
        const AT *AT = lookupATByEncoding(Encoding);
978
        // if (!AT || !AT->haveFeatures(STI.getFeatureBits()))
979
740
        if (!AT)
980
160
          return false;
981
982
580
        NeedsReg = true;
983
580
        Ins = "at";
984
580
        strncpy(Name, AT->Name, sizeof(Name) - 1);
985
580
      }
986
0
      break;
987
3.52k
    }
988
3.52k
  } else if (CnVal == 8) {
989
    // TLBI aliases
990
457
    const TLBI *TLBI = lookupTLBIByEncoding(Encoding);
991
    // if (!TLBI || !TLBI->haveFeatures(STI.getFeatureBits()))
992
457
    if (!TLBI)
993
270
      return false;
994
995
187
    NeedsReg = TLBI->NeedsReg;
996
187
    Ins = "tlbi";
997
187
    strncpy(Name, TLBI->Name, sizeof(Name) - 1);
998
187
  } else
999
246
    return false;
1000
1001
1.75k
  SStream_concat(O, "%s\t%s", Ins, Name);
1002
1003
1.75k
  if (NeedsReg) {
1004
1.21k
    SStream_concat(O, ", %s", getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, 4)), AArch64_NoRegAltName));
1005
1.21k
  }
1006
1007
1.75k
  MCInst_setOpcodePub(MI, AArch64_map_insn(Ins));
1008
1009
1.75k
  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
1.75k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
1019
1.75k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = AArch64_map_sys_op(Name);
1020
1.75k
    MI->flat_insn->detail->arm64.op_count++;
1021
1022
1.75k
    if (NeedsReg) {
1023
1.21k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1024
1.21k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 4));
1025
1.21k
      MI->flat_insn->detail->arm64.op_count++;
1026
1.21k
    }
1027
1.75k
  }
1028
1029
1.75k
  return true;
1030
4.22k
}
1031
1032
static void printOperand(MCInst *MI, unsigned OpNum, SStream *O)
1033
443k
{
1034
443k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1035
1036
443k
  if (MCOperand_isReg(Op)) {
1037
384k
    unsigned Reg = MCOperand_getReg(Op);
1038
1039
384k
    SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
1040
1041
384k
    if (MI->csh->detail) {
1042
384k
      if (MI->csh->doing_mem) {
1043
169k
        if (MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.base == ARM64_REG_INVALID) {
1044
149k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.base = Reg;
1045
149k
        }
1046
20.1k
        else if (MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.index == ARM64_REG_INVALID) {
1047
20.1k
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.index = Reg;
1048
20.1k
        }
1049
215k
      } 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
5.77k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count-1].sme_index.base = Reg;
1052
209k
      } else {
1053
209k
#ifndef CAPSTONE_DIET
1054
209k
        uint8_t access;
1055
1056
209k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1057
209k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1058
209k
        MI->ac_idx++;
1059
209k
#endif
1060
209k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1061
209k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
1062
209k
        MI->flat_insn->detail->arm64.op_count++;
1063
209k
      }
1064
384k
    }
1065
384k
  } else if (MCOperand_isImm(Op)) {
1066
58.5k
    int64_t imm = MCOperand_getImm(Op);
1067
1068
58.5k
    if (MI->Opcode == AArch64_ADR) {
1069
3.37k
      imm += MI->address;
1070
3.37k
      printUInt64Bang(O, imm);
1071
55.2k
    } else {
1072
55.2k
      if (MI->csh->doing_mem) {
1073
15.3k
        if (MI->csh->imm_unsigned) {
1074
0
          printUInt64Bang(O, imm);
1075
15.3k
        } else {
1076
15.3k
          printInt64Bang(O, imm);
1077
15.3k
        }
1078
15.3k
      } else
1079
39.8k
        printUInt64Bang(O, imm);
1080
55.2k
    }
1081
1082
58.5k
    if (MI->csh->detail) {
1083
58.5k
      if (MI->csh->doing_mem) {
1084
15.3k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = (int32_t)imm;
1085
43.2k
      } 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
43.2k
      } else {
1089
43.2k
#ifndef CAPSTONE_DIET
1090
43.2k
        uint8_t access;
1091
1092
43.2k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1093
43.2k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1094
43.2k
#endif
1095
43.2k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1096
43.2k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = imm;
1097
43.2k
        MI->flat_insn->detail->arm64.op_count++;
1098
43.2k
      }
1099
58.5k
    }
1100
58.5k
  }
1101
443k
}
1102
1103
static void printImm(MCInst *MI, unsigned OpNum, SStream *O)
1104
5.77k
{
1105
5.77k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1106
5.77k
  printUInt64Bang(O, MCOperand_getImm(Op));
1107
1108
5.77k
  if (MI->csh->detail) {
1109
5.77k
#ifndef CAPSTONE_DIET
1110
5.77k
    uint8_t access;
1111
5.77k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1112
5.77k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1113
5.77k
    MI->ac_idx++;
1114
5.77k
#endif
1115
5.77k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1116
5.77k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1117
5.77k
    MI->flat_insn->detail->arm64.op_count++;
1118
5.77k
  }
1119
5.77k
}
1120
1121
static void printImmHex(MCInst *MI, unsigned OpNum, SStream *O)
1122
59
{
1123
59
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1124
59
  printUInt64Bang(O, MCOperand_getImm(Op));
1125
1126
59
  if (MI->csh->detail) {
1127
59
#ifndef CAPSTONE_DIET
1128
59
    uint8_t access;
1129
59
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1130
59
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1131
59
    MI->ac_idx++;
1132
59
#endif
1133
59
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1134
59
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1135
59
    MI->flat_insn->detail->arm64.op_count++;
1136
59
  }
1137
59
}
1138
1139
1.83k
static void printSImm(MCInst *MI, unsigned OpNo, SStream *O, int Size) {
1140
1.83k
  MCOperand *Op = MCInst_getOperand(MI, OpNo);
1141
1.83k
  if (Size == 8)
1142
1.23k
  printInt64Bang(O, (signed char) MCOperand_getImm(Op));
1143
599
  else if (Size == 16)
1144
599
  printInt64Bang(O, (signed short) MCOperand_getImm(Op));
1145
0
  else
1146
0
    printInt64Bang(O, MCOperand_getImm(Op));
1147
1148
1.83k
  if (MI->csh->detail) {
1149
1.83k
#ifndef CAPSTONE_DIET
1150
1.83k
    uint8_t access;
1151
1.83k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1152
1.83k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1153
1.83k
    MI->ac_idx++;
1154
1.83k
#endif
1155
1.83k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1156
1.83k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1157
1.83k
    MI->flat_insn->detail->arm64.op_count++;
1158
1.83k
  }
1159
1.83k
}
1160
1161
static void printPostIncOperand(MCInst *MI, unsigned OpNum, SStream *O,
1162
    unsigned Imm)
1163
30.8k
{
1164
30.8k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1165
1166
30.8k
  if (MCOperand_isReg(Op)) {
1167
30.8k
    unsigned Reg = MCOperand_getReg(Op);
1168
30.8k
    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
30.8k
    } else {
1184
30.8k
      SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
1185
1186
30.8k
      if (MI->csh->detail) {
1187
30.8k
#ifndef CAPSTONE_DIET
1188
30.8k
        uint8_t access;
1189
1190
30.8k
        access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1191
30.8k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1192
30.8k
        MI->ac_idx++;
1193
30.8k
#endif
1194
30.8k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1195
30.8k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
1196
30.8k
        MI->flat_insn->detail->arm64.op_count++;
1197
30.8k
      }
1198
30.8k
    }
1199
30.8k
  }
1200
  //llvm_unreachable("unknown operand kind in printPostIncOperand64");
1201
30.8k
}
1202
1203
static void printVRegOperand(MCInst *MI, unsigned OpNum, SStream *O)
1204
56.7k
{
1205
56.7k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1206
  //assert(Op.isReg() && "Non-register vreg operand!");
1207
56.7k
  unsigned Reg = MCOperand_getReg(Op);
1208
1209
56.7k
  SStream_concat0(O, getRegisterName(Reg, AArch64_vreg));
1210
1211
56.7k
  if (MI->csh->detail) {
1212
56.7k
#ifndef CAPSTONE_DIET
1213
56.7k
    uint8_t access;
1214
56.7k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1215
56.7k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1216
56.7k
    MI->ac_idx++;
1217
56.7k
#endif
1218
56.7k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1219
56.7k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = AArch64_map_vregister(Reg);
1220
56.7k
    MI->flat_insn->detail->arm64.op_count++;
1221
56.7k
  }
1222
56.7k
}
1223
1224
static void printSysCROperand(MCInst *MI, unsigned OpNum, SStream *O)
1225
5.28k
{
1226
5.28k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1227
  //assert(Op.isImm() && "System instruction C[nm] operands must be immediates!");
1228
5.28k
  SStream_concat(O, "c%u", MCOperand_getImm(Op));
1229
1230
5.28k
  if (MI->csh->detail) {
1231
5.28k
#ifndef CAPSTONE_DIET
1232
5.28k
    uint8_t access;
1233
1234
5.28k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1235
5.28k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1236
5.28k
    MI->ac_idx++;
1237
5.28k
#endif
1238
5.28k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_CIMM;
1239
5.28k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
1240
5.28k
    MI->flat_insn->detail->arm64.op_count++;
1241
5.28k
  }
1242
5.28k
}
1243
1244
static void printAddSubImm(MCInst *MI, unsigned OpNum, SStream *O)
1245
2.99k
{
1246
2.99k
  MCOperand *MO = MCInst_getOperand(MI, OpNum);
1247
2.99k
  if (MCOperand_isImm(MO)) {
1248
2.99k
    unsigned Val = (MCOperand_getImm(MO) & 0xfff);
1249
    //assert(Val == MO.getImm() && "Add/sub immediate out of range!");
1250
2.99k
    unsigned Shift = AArch64_AM_getShiftValue((int)MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1)));
1251
1252
2.99k
    printInt32Bang(O, Val);
1253
1254
2.99k
    if (MI->csh->detail) {
1255
2.99k
#ifndef CAPSTONE_DIET
1256
2.99k
      uint8_t access;
1257
1258
2.99k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1259
2.99k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1260
2.99k
      MI->ac_idx++;
1261
2.99k
#endif
1262
2.99k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1263
2.99k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
1264
2.99k
      MI->flat_insn->detail->arm64.op_count++;
1265
2.99k
    }
1266
1267
2.99k
    if (Shift != 0)
1268
1.69k
      printShifter(MI, OpNum + 1, O);
1269
2.99k
  }
1270
2.99k
}
1271
1272
static void printLogicalImm32(MCInst *MI, unsigned OpNum, SStream *O)
1273
3.87k
{
1274
3.87k
  int64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1275
1276
3.87k
  Val = AArch64_AM_decodeLogicalImmediate(Val, 32);
1277
3.87k
  printUInt32Bang(O, (int)Val);
1278
1279
3.87k
  if (MI->csh->detail) {
1280
3.87k
#ifndef CAPSTONE_DIET
1281
3.87k
    uint8_t access;
1282
1283
3.87k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1284
3.87k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1285
3.87k
    MI->ac_idx++;
1286
3.87k
#endif
1287
3.87k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1288
3.87k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
1289
3.87k
    MI->flat_insn->detail->arm64.op_count++;
1290
3.87k
  }
1291
3.87k
}
1292
1293
static void printLogicalImm64(MCInst *MI, unsigned OpNum, SStream *O)
1294
2.66k
{
1295
2.66k
  int64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1296
2.66k
  Val = AArch64_AM_decodeLogicalImmediate(Val, 64);
1297
1298
2.66k
  switch(MI->flat_insn->id) {
1299
890
    default:
1300
890
      printInt64Bang(O, Val);
1301
890
      break;
1302
1303
312
    case ARM64_INS_ORR:
1304
1.56k
    case ARM64_INS_AND:
1305
1.77k
    case ARM64_INS_EOR:
1306
1.77k
    case ARM64_INS_TST:
1307
      // do not print number in negative form
1308
1.77k
      if (Val >= 0 && Val <= HEX_THRESHOLD)
1309
71
        SStream_concat(O, "#%u", (int)Val);
1310
1.69k
      else
1311
1.69k
        SStream_concat(O, "#0x%"PRIx64, Val);
1312
1.77k
      break;
1313
2.66k
  }
1314
1315
2.66k
  if (MI->csh->detail) {
1316
2.66k
#ifndef CAPSTONE_DIET
1317
2.66k
    uint8_t access;
1318
1319
2.66k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1320
2.66k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1321
2.66k
    MI->ac_idx++;
1322
2.66k
#endif
1323
2.66k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1324
2.66k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = (int64_t)Val;
1325
2.66k
    MI->flat_insn->detail->arm64.op_count++;
1326
2.66k
  }
1327
2.66k
}
1328
1329
static void printShifter(MCInst *MI, unsigned OpNum, SStream *O)
1330
13.7k
{
1331
13.7k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1332
1333
  // LSL #0 should not be printed.
1334
13.7k
  if (AArch64_AM_getShiftType(Val) == AArch64_AM_LSL &&
1335
7.89k
      AArch64_AM_getShiftValue(Val) == 0)
1336
1.25k
    return;
1337
1338
12.4k
  SStream_concat(O, ", %s ", AArch64_AM_getShiftExtendName(AArch64_AM_getShiftType(Val)));
1339
12.4k
  printInt32BangDec(O, AArch64_AM_getShiftValue(Val));
1340
1341
12.4k
  if (MI->csh->detail) {
1342
12.4k
    arm64_shifter shifter = ARM64_SFT_INVALID;
1343
1344
12.4k
    switch(AArch64_AM_getShiftType(Val)) {
1345
0
      default:  // never reach
1346
6.64k
      case AArch64_AM_LSL:
1347
6.64k
        shifter = ARM64_SFT_LSL;
1348
6.64k
        break;
1349
1350
2.11k
      case AArch64_AM_LSR:
1351
2.11k
        shifter = ARM64_SFT_LSR;
1352
2.11k
        break;
1353
1354
1.85k
      case AArch64_AM_ASR:
1355
1.85k
        shifter = ARM64_SFT_ASR;
1356
1.85k
        break;
1357
1358
1.17k
      case AArch64_AM_ROR:
1359
1.17k
        shifter = ARM64_SFT_ROR;
1360
1.17k
        break;
1361
1362
699
      case AArch64_AM_MSL:
1363
699
        shifter = ARM64_SFT_MSL;
1364
699
        break;
1365
12.4k
    }
1366
1367
12.4k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.type = shifter;
1368
12.4k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.value = AArch64_AM_getShiftValue(Val);
1369
12.4k
  }
1370
12.4k
}
1371
1372
static void printShiftedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1373
7.46k
{
1374
7.46k
  SStream_concat0(O, getRegisterName(MCOperand_getReg(MCInst_getOperand(MI, OpNum)), AArch64_NoRegAltName));
1375
1376
7.46k
  if (MI->csh->detail) {
1377
7.46k
#ifndef CAPSTONE_DIET
1378
7.46k
    uint8_t access;
1379
7.46k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1380
7.46k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1381
7.46k
    MI->ac_idx++;
1382
7.46k
#endif
1383
7.46k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1384
7.46k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1385
7.46k
    MI->flat_insn->detail->arm64.op_count++;
1386
7.46k
  }
1387
1388
7.46k
  printShifter(MI, OpNum + 1, O);
1389
7.46k
}
1390
1391
static void printArithExtend(MCInst *MI, unsigned OpNum, SStream *O)
1392
3.05k
{
1393
3.05k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1394
3.05k
  AArch64_AM_ShiftExtendType ExtType = AArch64_AM_getArithExtendType(Val);
1395
3.05k
  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
3.05k
  if (ExtType == AArch64_AM_UXTW || ExtType == AArch64_AM_UXTX) {
1401
1.81k
    unsigned Dest = MCOperand_getReg(MCInst_getOperand(MI, 0));
1402
1.81k
    unsigned Src1 = MCOperand_getReg(MCInst_getOperand(MI, 1));
1403
1404
1.81k
    if (((Dest == AArch64_SP || Src1 == AArch64_SP) &&
1405
410
          ExtType == AArch64_AM_UXTX) ||
1406
1.70k
        ((Dest == AArch64_WSP || Src1 == AArch64_WSP) &&
1407
278
         ExtType == AArch64_AM_UXTW)) {
1408
205
      if (ShiftVal != 0) {
1409
205
        SStream_concat0(O, ", lsl ");
1410
205
        printInt32Bang(O, ShiftVal);
1411
1412
205
        if (MI->csh->detail) {
1413
205
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.type = ARM64_SFT_LSL;
1414
205
          MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.value = ShiftVal;
1415
205
        }
1416
205
      }
1417
1418
205
      return;
1419
205
    }
1420
1.81k
  }
1421
1422
2.85k
  SStream_concat(O, ", %s", AArch64_AM_getShiftExtendName(ExtType));
1423
1424
2.85k
  if (MI->csh->detail) {
1425
2.85k
    arm64_extender ext = ARM64_EXT_INVALID;
1426
2.85k
    switch(ExtType) {
1427
0
      default:  // never reach
1428
1429
200
      case AArch64_AM_UXTB:
1430
200
        ext = ARM64_EXT_UXTB;
1431
200
        break;
1432
1433
419
      case AArch64_AM_UXTH:
1434
419
        ext = ARM64_EXT_UXTH;
1435
419
        break;
1436
1437
1.34k
      case AArch64_AM_UXTW:
1438
1.34k
        ext = ARM64_EXT_UXTW;
1439
1.34k
        break;
1440
1441
268
      case AArch64_AM_UXTX:
1442
268
        ext = ARM64_EXT_UXTX;
1443
268
        break;
1444
1445
77
      case AArch64_AM_SXTB:
1446
77
        ext = ARM64_EXT_SXTB;
1447
77
        break;
1448
1449
107
      case AArch64_AM_SXTH:
1450
107
        ext = ARM64_EXT_SXTH;
1451
107
        break;
1452
1453
105
      case AArch64_AM_SXTW:
1454
105
        ext = ARM64_EXT_SXTW;
1455
105
        break;
1456
1457
334
      case AArch64_AM_SXTX:
1458
334
        ext = ARM64_EXT_SXTX;
1459
334
        break;
1460
2.85k
    }
1461
1462
2.85k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].ext = ext;
1463
2.85k
  }
1464
1465
2.85k
  if (ShiftVal != 0) {
1466
2.60k
    SStream_concat0(O, " ");
1467
2.60k
    printInt32Bang(O, ShiftVal);
1468
1469
2.60k
    if (MI->csh->detail) {
1470
2.60k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.type = ARM64_SFT_LSL;
1471
2.60k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].shift.value = ShiftVal;
1472
2.60k
    }
1473
2.60k
  }
1474
2.85k
}
1475
1476
static void printExtendedRegister(MCInst *MI, unsigned OpNum, SStream *O)
1477
1.90k
{
1478
1.90k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1479
1480
1.90k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
1481
1482
1.90k
  if (MI->csh->detail) {
1483
1.90k
#ifndef CAPSTONE_DIET
1484
1.90k
    uint8_t access;
1485
1.90k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1486
1.90k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1487
1.90k
    MI->ac_idx++;
1488
1.90k
#endif
1489
1.90k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1490
1.90k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
1491
1.90k
    MI->flat_insn->detail->arm64.op_count++;
1492
1.90k
  }
1493
1494
1.90k
  printArithExtend(MI, OpNum + 1, O);
1495
1.90k
}
1496
1497
static void printMemExtendImpl(MCInst *MI, bool SignExtend, bool DoShift, unsigned Width,
1498
             char SrcRegKind, SStream *O)
1499
20.4k
{
1500
  // sxtw, sxtx, uxtw or lsl (== uxtx)
1501
20.4k
  bool IsLSL = !SignExtend && SrcRegKind == 'x';
1502
20.4k
  if (IsLSL) {
1503
7.43k
    SStream_concat0(O, "lsl");
1504
1505
7.43k
    if (MI->csh->detail) {
1506
7.43k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].shift.type = ARM64_SFT_LSL;
1507
7.43k
    }
1508
13.0k
  } else {
1509
13.0k
    SStream_concat(O, "%cxt%c", (SignExtend ? 's' : 'u'), SrcRegKind);
1510
1511
13.0k
    if (MI->csh->detail) {
1512
13.0k
      if (!SignExtend) {
1513
6.75k
        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.75k
          case 'w':
1522
6.75k
               MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_UXTW;
1523
6.75k
               break;
1524
6.75k
        }
1525
6.75k
      } else {
1526
6.27k
          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
5.39k
            case 'w':
1535
5.39k
              MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_SXTW;
1536
5.39k
              break;
1537
880
            case 'x':
1538
880
              MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_SXTX;
1539
880
              break;
1540
6.27k
          }
1541
6.27k
      }
1542
13.0k
    }
1543
13.0k
  }
1544
1545
20.4k
  if (DoShift || IsLSL) {
1546
13.9k
    SStream_concat(O, " #%u", Log2_32(Width / 8));
1547
1548
13.9k
    if (MI->csh->detail) {
1549
13.9k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].shift.type = ARM64_SFT_LSL;
1550
13.9k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].shift.value = Log2_32(Width / 8);
1551
13.9k
    }
1552
13.9k
  }
1553
20.4k
}
1554
1555
static void printMemExtend(MCInst *MI, unsigned OpNum, SStream *O, char SrcRegKind, unsigned Width)
1556
5.97k
{
1557
5.97k
  unsigned SignExtend = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1558
5.97k
  unsigned DoShift = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1));
1559
1560
5.97k
  printMemExtendImpl(MI, SignExtend, DoShift, Width, SrcRegKind, O);
1561
5.97k
}
1562
1563
static void printRegWithShiftExtend(MCInst *MI, unsigned OpNum, SStream *O,
1564
            bool SignExtend, int ExtWidth,
1565
            char SrcRegKind, char Suffix)
1566
16.3k
{
1567
16.3k
  bool DoShift;
1568
1569
16.3k
  printOperand(MI, OpNum, O);
1570
1571
16.3k
  if (Suffix == 's' || Suffix == 'd')
1572
12.2k
    SStream_concat(O, ".%c", Suffix);
1573
1574
16.3k
  DoShift = ExtWidth != 8;
1575
16.3k
  if (SignExtend || DoShift || SrcRegKind == 'w') {
1576
14.4k
    SStream_concat0(O, ", ");
1577
14.4k
    printMemExtendImpl(MI, SignExtend, DoShift, ExtWidth, SrcRegKind, O);
1578
14.4k
  }
1579
16.3k
}
1580
1581
static void printCondCode(MCInst *MI, unsigned OpNum, SStream *O)
1582
3.07k
{
1583
3.07k
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1584
3.07k
  SStream_concat0(O, getCondCodeName(CC));
1585
1586
3.07k
  if (MI->csh->detail)
1587
3.07k
    MI->flat_insn->detail->arm64.cc = (arm64_cc)(CC + 1);
1588
3.07k
}
1589
1590
static void printInverseCondCode(MCInst *MI, unsigned OpNum, SStream *O)
1591
965
{
1592
965
  AArch64CC_CondCode CC = (AArch64CC_CondCode)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1593
965
  SStream_concat0(O, getCondCodeName(getInvertedCondCode(CC)));
1594
1595
965
  if (MI->csh->detail) {
1596
965
    MI->flat_insn->detail->arm64.cc = (arm64_cc)(getInvertedCondCode(CC) + 1);
1597
965
  }
1598
965
}
1599
1600
static void printImmScale(MCInst *MI, unsigned OpNum, SStream *O, int Scale)
1601
24.0k
{
1602
24.0k
  int64_t val = Scale * MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1603
1604
24.0k
  printInt64Bang(O, val);
1605
1606
24.0k
  if (MI->csh->detail) {
1607
24.0k
    if (MI->csh->doing_mem) {
1608
19.5k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = (int32_t)val;
1609
19.5k
    } else {
1610
4.55k
#ifndef CAPSTONE_DIET
1611
4.55k
      uint8_t access;
1612
1613
4.55k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1614
4.55k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1615
4.55k
      MI->ac_idx++;
1616
4.55k
#endif
1617
4.55k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
1618
4.55k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = val;
1619
4.55k
      MI->flat_insn->detail->arm64.op_count++;
1620
4.55k
    }
1621
24.0k
  }
1622
24.0k
}
1623
1624
static void printUImm12Offset(MCInst *MI, unsigned OpNum, SStream *O, unsigned Scale)
1625
9.16k
{
1626
9.16k
  MCOperand *MO = MCInst_getOperand(MI, OpNum);
1627
1628
9.16k
  if (MCOperand_isImm(MO)) {
1629
9.16k
    int64_t val = Scale * MCOperand_getImm(MO);
1630
9.16k
    printInt64Bang(O, val);
1631
1632
9.16k
    if (MI->csh->detail) {
1633
9.16k
      if (MI->csh->doing_mem) {
1634
9.16k
        MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = (int32_t)val;
1635
9.16k
      } 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
9.16k
    }
1648
9.16k
  }
1649
9.16k
}
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
7.55k
{
1674
7.55k
  unsigned prfop = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1675
1676
7.55k
  if (IsSVEPrefetch) {
1677
5.78k
    const SVEPRFM *PRFM = lookupSVEPRFMByEncoding(prfop);
1678
5.78k
    if (PRFM)
1679
4.63k
      SStream_concat0(O, PRFM->Name);
1680
1681
5.78k
    return;
1682
5.78k
  } else {
1683
1.77k
    const PRFM *PRFM = lookupPRFMByEncoding(prfop);
1684
1.77k
    if (PRFM)
1685
962
      SStream_concat0(O, PRFM->Name);
1686
1687
1.77k
    return;
1688
1.77k
  }
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
832
{
1709
832
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
1710
832
  unsigned int psbhintop = MCOperand_getImm(Op);
1711
1712
832
  const PSB *PSB = lookupPSBByEncoding(psbhintop);
1713
832
  if (PSB)
1714
832
    SStream_concat0(O, PSB->Name);
1715
0
  else
1716
0
    printUInt32Bang(O, psbhintop);
1717
832
}
1718
1719
422
static void printBTIHintOp(MCInst *MI, unsigned OpNum, SStream *O) {
1720
422
  unsigned btihintop = MCOperand_getImm(MCInst_getOperand(MI, OpNum)) ^ 32;
1721
1722
422
  const BTI *BTI = lookupBTIByEncoding(btihintop);
1723
422
  if (BTI)
1724
422
  SStream_concat0(O, BTI->Name);
1725
0
  else
1726
0
  printUInt32Bang(O, btihintop);
1727
422
}
1728
1729
static void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1730
969
{
1731
969
  MCOperand *MO = MCInst_getOperand(MI, OpNum);
1732
969
  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
969
  SStream_concat(O, "#%.8f", FPImm);
1740
969
#endif
1741
1742
969
  if (MI->csh->detail) {
1743
969
#ifndef CAPSTONE_DIET
1744
969
    uint8_t access;
1745
1746
969
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1747
969
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1748
969
    MI->ac_idx++;
1749
969
#endif
1750
969
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_FP;
1751
969
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].fp = FPImm;
1752
969
    MI->flat_insn->detail->arm64.op_count++;
1753
969
  }
1754
969
}
1755
1756
//static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride = 1)
1757
static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride)
1758
184k
{
1759
368k
  while (Stride--) {
1760
184k
    if (Reg >= AArch64_Q0 && Reg <= AArch64_Q30) // AArch64_Q0 .. AArch64_Q30
1761
161k
      Reg += 1;
1762
22.8k
    else if (Reg == AArch64_Q31) // Vector lists can wrap around.
1763
6.02k
      Reg = AArch64_Q0;
1764
16.8k
    else if (Reg >= AArch64_Z0 && Reg <= AArch64_Z30) // AArch64_Z0 .. AArch64_Z30
1765
15.9k
      Reg += 1;
1766
862
    else if (Reg == AArch64_Z31) // Vector lists can wrap around.
1767
862
      Reg = AArch64_Z0;
1768
184k
  }
1769
1770
184k
  return Reg;
1771
184k
}
1772
1773
static void printGPRSeqPairsClassOperand(MCInst *MI, unsigned OpNum, SStream *O, unsigned int size)
1774
3.75k
{
1775
  // static_assert(size == 64 || size == 32,
1776
  //    "Template parameter must be either 32 or 64");
1777
3.75k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1778
3.75k
  unsigned Sube = (size == 32) ? AArch64_sube32 : AArch64_sube64;
1779
3.75k
  unsigned Subo = (size == 32) ? AArch64_subo32 : AArch64_subo64;
1780
3.75k
  unsigned Even = MCRegisterInfo_getSubReg(MI->MRI, Reg, Sube);
1781
3.75k
  unsigned Odd = MCRegisterInfo_getSubReg(MI->MRI, Reg, Subo);
1782
1783
3.75k
  SStream_concat(O, "%s, %s", getRegisterName(Even, AArch64_NoRegAltName),
1784
3.75k
      getRegisterName(Odd, AArch64_NoRegAltName));
1785
1786
3.75k
  if (MI->csh->detail) {
1787
3.75k
#ifndef CAPSTONE_DIET
1788
3.75k
    uint8_t access;
1789
1790
3.75k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1791
3.75k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1792
3.75k
    MI->ac_idx++;
1793
3.75k
#endif
1794
1795
3.75k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1796
3.75k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Even;
1797
3.75k
    MI->flat_insn->detail->arm64.op_count++;
1798
1799
3.75k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1800
3.75k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Odd;
1801
3.75k
    MI->flat_insn->detail->arm64.op_count++;
1802
3.75k
  }
1803
3.75k
}
1804
1805
static void printVectorList(MCInst *MI, unsigned OpNum, SStream *O,
1806
    char *LayoutSuffix, MCRegisterInfo *MRI, arm64_vas vas)
1807
76.1k
{
1808
1.11M
#define GETREGCLASS_CONTAIN0(_class, _reg) MCRegisterClass_contains(MCRegisterInfo_getRegClass(MRI, _class), _reg)
1809
76.1k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
1810
76.1k
  unsigned NumRegs = 1, FirstReg, i;
1811
1812
76.1k
  SStream_concat0(O, "{");
1813
1814
  // Work out how many registers there are in the list (if there is an actual
1815
  // list).
1816
76.1k
  if (GETREGCLASS_CONTAIN0(AArch64_DDRegClassID , Reg) ||
1817
71.8k
      GETREGCLASS_CONTAIN0(AArch64_ZPR2RegClassID, Reg) ||
1818
70.7k
      GETREGCLASS_CONTAIN0(AArch64_QQRegClassID, Reg))
1819
17.7k
    NumRegs = 2;
1820
58.3k
  else if (GETREGCLASS_CONTAIN0(AArch64_DDDRegClassID, Reg) ||
1821
55.2k
      GETREGCLASS_CONTAIN0(AArch64_ZPR3RegClassID, Reg) ||
1822
54.2k
      GETREGCLASS_CONTAIN0(AArch64_QQQRegClassID, Reg))
1823
17.4k
    NumRegs = 3;
1824
40.9k
  else if (GETREGCLASS_CONTAIN0(AArch64_DDDDRegClassID, Reg) ||
1825
36.6k
      GETREGCLASS_CONTAIN0(AArch64_ZPR4RegClassID, Reg) ||
1826
36.3k
      GETREGCLASS_CONTAIN0(AArch64_QQQQRegClassID, Reg))
1827
18.5k
    NumRegs = 4;
1828
1829
  // Now forget about the list and find out what the first register is.
1830
76.1k
  if ((FirstReg = MCRegisterInfo_getSubReg(MRI, Reg, AArch64_dsub0)))
1831
11.7k
    Reg = FirstReg;
1832
64.3k
  else if ((FirstReg = MCRegisterInfo_getSubReg(MRI, Reg, AArch64_qsub0)))
1833
39.6k
    Reg = FirstReg;
1834
24.7k
  else if ((FirstReg = MCRegisterInfo_getSubReg(MRI, Reg, AArch64_zsub0)))
1835
2.35k
    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
76.1k
  if (GETREGCLASS_CONTAIN0(AArch64_FPR64RegClassID, Reg)) {
1840
13.1k
    const MCRegisterClass *FPR128RC = MCRegisterInfo_getRegClass(MRI, AArch64_FPR128RegClassID);
1841
13.1k
    Reg = MCRegisterInfo_getMatchingSuperReg(MRI, Reg, AArch64_dsub, FPR128RC);
1842
13.1k
  }
1843
1844
260k
  for (i = 0; i < NumRegs; ++i, Reg = getNextVectorRegister(Reg, 1)) {
1845
184k
    bool isZReg = GETREGCLASS_CONTAIN0(AArch64_ZPRRegClassID, Reg);
1846
184k
    if (isZReg)
1847
16.8k
      SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_NoRegAltName), LayoutSuffix);
1848
167k
    else
1849
167k
      SStream_concat(O, "%s%s", getRegisterName(Reg, AArch64_vreg), LayoutSuffix);
1850
1851
184k
    if (MI->csh->detail) {
1852
184k
#ifndef CAPSTONE_DIET
1853
184k
      uint8_t access;
1854
1855
184k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
1856
184k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
1857
184k
      MI->ac_idx++;
1858
184k
#endif
1859
184k
      unsigned regForDetail = isZReg ? Reg : AArch64_map_vregister(Reg);
1860
184k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
1861
184k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = regForDetail;
1862
184k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].vas = vas;
1863
184k
      MI->flat_insn->detail->arm64.op_count++;
1864
184k
    }
1865
1866
184k
    if (i + 1 != NumRegs)
1867
108k
      SStream_concat0(O, ", ");
1868
184k
  }
1869
1870
76.1k
  SStream_concat0(O, "}");
1871
76.1k
}
1872
1873
static void printTypedVectorList(MCInst *MI, unsigned OpNum, SStream *O, unsigned NumLanes, char LaneKind)
1874
76.1k
{
1875
76.1k
  char Suffix[32];
1876
76.1k
  arm64_vas vas = 0;
1877
1878
76.1k
  if (NumLanes) {
1879
33.0k
    cs_snprintf(Suffix, sizeof(Suffix), ".%u%c", NumLanes, LaneKind);
1880
1881
33.0k
    switch(LaneKind) {
1882
0
      default: break;
1883
9.31k
      case 'b':
1884
9.31k
        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.25k
          case 8:
1893
3.25k
               vas = ARM64_VAS_8B;
1894
3.25k
               break;
1895
6.06k
          case 16:
1896
6.06k
               vas = ARM64_VAS_16B;
1897
6.06k
               break;
1898
9.31k
        }
1899
9.31k
        break;
1900
9.53k
      case 'h':
1901
9.53k
        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.54k
          case 4:
1910
3.54k
               vas = ARM64_VAS_4H;
1911
3.54k
               break;
1912
5.98k
          case 8:
1913
5.98k
               vas = ARM64_VAS_8H;
1914
5.98k
               break;
1915
9.53k
        }
1916
9.53k
        break;
1917
9.53k
      case 's':
1918
8.63k
        switch(NumLanes) {
1919
0
          default: break;
1920
0
          case 1:
1921
0
               vas = ARM64_VAS_1S;
1922
0
               break;
1923
4.20k
          case 2:
1924
4.20k
               vas = ARM64_VAS_2S;
1925
4.20k
               break;
1926
4.42k
          case 4:
1927
4.42k
               vas = ARM64_VAS_4S;
1928
4.42k
               break;
1929
8.63k
        }
1930
8.63k
        break;
1931
8.63k
      case 'd':
1932
5.54k
        switch(NumLanes) {
1933
0
          default: break;
1934
2.12k
          case 1:
1935
2.12k
               vas = ARM64_VAS_1D;
1936
2.12k
               break;
1937
3.42k
          case 2:
1938
3.42k
               vas = ARM64_VAS_2D;
1939
3.42k
               break;
1940
5.54k
        }
1941
5.54k
        break;
1942
5.54k
      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
33.0k
    }
1951
43.1k
  } else {
1952
43.1k
    cs_snprintf(Suffix, sizeof(Suffix), ".%c", LaneKind);
1953
1954
43.1k
    switch(LaneKind) {
1955
0
      default: break;
1956
9.94k
      case 'b':
1957
9.94k
           vas = ARM64_VAS_1B;
1958
9.94k
           break;
1959
9.63k
      case 'h':
1960
9.63k
           vas = ARM64_VAS_1H;
1961
9.63k
           break;
1962
9.23k
      case 's':
1963
9.23k
           vas = ARM64_VAS_1S;
1964
9.23k
           break;
1965
14.2k
      case 'd':
1966
14.2k
           vas = ARM64_VAS_1D;
1967
14.2k
           break;
1968
0
      case 'q':
1969
0
           vas = ARM64_VAS_1Q;
1970
0
           break;
1971
43.1k
    }
1972
43.1k
  }
1973
1974
76.1k
  printVectorList(MI, OpNum, O, Suffix, MI->MRI, vas);
1975
76.1k
}
1976
1977
static void printVectorIndex(MCInst *MI, unsigned OpNum, SStream *O)
1978
42.9k
{
1979
42.9k
  SStream_concat0(O, "[");
1980
42.9k
  printInt32(O, (int)MCOperand_getImm(MCInst_getOperand(MI, OpNum)));
1981
42.9k
  SStream_concat0(O, "]");
1982
1983
42.9k
  if (MI->csh->detail) {
1984
42.9k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count - 1].vector_index = (int)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
1985
42.9k
  }
1986
42.9k
}
1987
1988
static void printAlignedLabel(MCInst *MI, unsigned OpNum, SStream *O)
1989
13.1k
{
1990
13.1k
  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
13.1k
  if (MCOperand_isImm(Op)) {
1995
13.1k
    uint64_t imm = (MCOperand_getImm(Op) * 4) + MI->address;
1996
13.1k
    printUInt64Bang(O, imm);
1997
1998
13.1k
    if (MI->csh->detail) {
1999
13.1k
#ifndef CAPSTONE_DIET
2000
13.1k
      uint8_t access;
2001
2002
13.1k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2003
13.1k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2004
13.1k
      MI->ac_idx++;
2005
13.1k
#endif
2006
13.1k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2007
13.1k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = imm;
2008
13.1k
      MI->flat_insn->detail->arm64.op_count++;
2009
13.1k
    }
2010
13.1k
  }
2011
13.1k
}
2012
2013
static void printAdrpLabel(MCInst *MI, unsigned OpNum, SStream *O)
2014
1.42k
{
2015
1.42k
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
2016
2017
1.42k
  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.42k
    uint64_t imm = (MCOperand_getImm(Op) * 0x1000) + (MI->address & ~0xfff);
2021
1.42k
    printUInt64Bang(O, imm);
2022
2023
1.42k
    if (MI->csh->detail) {
2024
1.42k
#ifndef CAPSTONE_DIET
2025
1.42k
      uint8_t access;
2026
2027
1.42k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2028
1.42k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2029
1.42k
      MI->ac_idx++;
2030
1.42k
#endif
2031
1.42k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2032
1.42k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = imm;
2033
1.42k
      MI->flat_insn->detail->arm64.op_count++;
2034
1.42k
    }
2035
1.42k
  }
2036
1.42k
}
2037
2038
static void printBarrierOption(MCInst *MI, unsigned OpNum, SStream *O)
2039
1.06k
{
2040
1.06k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2041
1.06k
  unsigned Opcode = MCInst_getOpcode(MI);
2042
1.06k
  const char *Name = NULL;
2043
2044
1.06k
  if (Opcode == AArch64_ISB) {
2045
262
    const ISB *ISB = lookupISBByEncoding(Val);
2046
262
    Name = ISB ? ISB->Name : NULL;
2047
798
  } else if (Opcode == AArch64_TSB) {
2048
0
    const TSB *TSB = lookupTSBByEncoding(Val);
2049
0
    Name = TSB ? TSB->Name : NULL;
2050
798
  } else {
2051
798
    const DB *DB = lookupDBByEncoding(Val);
2052
798
    Name = DB ? DB->Name : NULL;
2053
798
  }
2054
2055
1.06k
  if (Name) {
2056
126
    SStream_concat0(O, Name);
2057
2058
126
    if (MI->csh->detail) {
2059
126
#ifndef CAPSTONE_DIET
2060
126
      uint8_t access;
2061
2062
126
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2063
126
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2064
126
      MI->ac_idx++;
2065
126
#endif
2066
126
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_BARRIER;
2067
126
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].barrier = Val;
2068
126
      MI->flat_insn->detail->arm64.op_count++;
2069
126
    }
2070
934
  } else {
2071
934
    printUInt32Bang(O, Val);
2072
2073
934
    if (MI->csh->detail) {
2074
934
#ifndef CAPSTONE_DIET
2075
934
      uint8_t access;
2076
2077
934
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2078
934
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2079
934
      MI->ac_idx++;
2080
934
#endif
2081
934
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2082
934
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
2083
934
      MI->flat_insn->detail->arm64.op_count++;
2084
934
    }
2085
934
  }
2086
1.06k
}
2087
2088
162
static void printBarriernXSOption(MCInst *MI, unsigned OpNo, SStream *O) {
2089
162
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, OpNo));
2090
  // assert(MI->getOpcode() == AArch64::DSBnXS);
2091
2092
162
  const char *Name = NULL;
2093
162
  const DBnXS *DB = lookupDBnXSByEncoding(Val);
2094
162
  Name = DB ? DB->Name : NULL;
2095
2096
162
  if (Name) {
2097
162
    SStream_concat0(O, Name);
2098
2099
162
    if (MI->csh->detail) {
2100
162
#ifndef CAPSTONE_DIET
2101
162
      uint8_t access;
2102
2103
162
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2104
162
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2105
162
      MI->ac_idx++;
2106
162
#endif
2107
162
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_BARRIER;
2108
162
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].barrier = Val;
2109
162
      MI->flat_insn->detail->arm64.op_count++;
2110
162
    }
2111
162
  }
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
162
}
2129
2130
static void printMRSSystemRegister(MCInst *MI, unsigned OpNum, SStream *O)
2131
1.87k
{
2132
1.87k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2133
1.87k
  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
1.87k
  if (Val == ARM64_SYSREG_DBGDTRRX_EL0) {
2139
37
    SStream_concat0(O, "dbgdtrrx_el0");
2140
2141
37
    if (MI->csh->detail) {
2142
37
#ifndef CAPSTONE_DIET
2143
37
      uint8_t access;
2144
2145
37
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2146
37
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2147
37
      MI->ac_idx++;
2148
37
#endif
2149
2150
37
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2151
37
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2152
37
      MI->flat_insn->detail->arm64.op_count++;
2153
37
    }
2154
2155
37
    return;
2156
37
  }
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
1.83k
  if( Val == ARM64_SYSREG_VSCTLR_EL2){
2161
263
    SStream_concat0(O, "ttbr0_el2");
2162
2163
263
    if (MI->csh->detail) {
2164
263
#ifndef CAPSTONE_DIET
2165
263
      uint8_t access;
2166
2167
263
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2168
263
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2169
263
      MI->ac_idx++;
2170
263
#endif
2171
2172
263
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2173
263
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2174
263
      MI->flat_insn->detail->arm64.op_count++;
2175
263
    }
2176
2177
263
    return;
2178
263
  }
2179
2180
  // if (Reg && Reg->Readable && Reg->haveFeatures(STI.getFeatureBits()))
2181
1.57k
  if (Reg && Reg->Readable) {
2182
173
    SStream_concat0(O, Reg->Name);
2183
2184
173
    if (MI->csh->detail) {
2185
173
#ifndef CAPSTONE_DIET
2186
173
      uint8_t access;
2187
2188
173
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2189
173
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2190
173
      MI->ac_idx++;
2191
173
#endif
2192
2193
173
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2194
173
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Reg->Encoding;
2195
173
      MI->flat_insn->detail->arm64.op_count++;
2196
173
    }
2197
1.39k
  } else {
2198
1.39k
    char result[128];
2199
2200
1.39k
    AArch64SysReg_genericRegisterString(Val, result);
2201
1.39k
    SStream_concat0(O, result);
2202
2203
1.39k
    if (MI->csh->detail) {
2204
1.39k
#ifndef CAPSTONE_DIET
2205
1.39k
      uint8_t access;
2206
1.39k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2207
1.39k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2208
1.39k
      MI->ac_idx++;
2209
1.39k
#endif
2210
1.39k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG_MRS;
2211
1.39k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Val;
2212
1.39k
      MI->flat_insn->detail->arm64.op_count++;
2213
1.39k
    }
2214
1.39k
  }
2215
1.57k
}
2216
2217
static void printMSRSystemRegister(MCInst *MI, unsigned OpNum, SStream *O)
2218
4.21k
{
2219
4.21k
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2220
4.21k
  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
4.21k
  if (Val == ARM64_SYSREG_DBGDTRTX_EL0) {
2226
68
    SStream_concat0(O, "dbgdtrtx_el0");
2227
2228
68
    if (MI->csh->detail) {
2229
68
#ifndef CAPSTONE_DIET
2230
68
      uint8_t access;
2231
2232
68
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2233
68
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2234
68
      MI->ac_idx++;
2235
68
#endif
2236
2237
68
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2238
68
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2239
68
      MI->flat_insn->detail->arm64.op_count++;
2240
68
    }
2241
2242
68
    return;
2243
68
  }
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
4.15k
  if( Val == ARM64_SYSREG_VSCTLR_EL2){
2248
409
    SStream_concat0(O, "ttbr0_el2");
2249
2250
409
    if (MI->csh->detail) {
2251
409
#ifndef CAPSTONE_DIET
2252
409
      uint8_t access;
2253
2254
409
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2255
409
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2256
409
      MI->ac_idx++;
2257
409
#endif
2258
2259
409
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2260
409
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Val;
2261
409
      MI->flat_insn->detail->arm64.op_count++;
2262
409
    }
2263
2264
409
    return;
2265
409
  }
2266
2267
  // if (Reg && Reg->Writeable && Reg->haveFeatures(STI.getFeatureBits()))
2268
3.74k
  if (Reg && Reg->Writeable) {
2269
324
    SStream_concat0(O, Reg->Name);
2270
2271
324
    if (MI->csh->detail) {
2272
324
#ifndef CAPSTONE_DIET
2273
324
      uint8_t access;
2274
2275
324
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2276
324
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2277
324
      MI->ac_idx++;
2278
324
#endif
2279
2280
324
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_SYS;
2281
324
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].sys = Reg->Encoding;
2282
324
      MI->flat_insn->detail->arm64.op_count++;
2283
324
    }
2284
3.41k
  } else {
2285
3.41k
    char result[128];
2286
2287
3.41k
    AArch64SysReg_genericRegisterString(Val, result);
2288
3.41k
    SStream_concat0(O, result);
2289
2290
3.41k
    if (MI->csh->detail) {
2291
3.41k
#ifndef CAPSTONE_DIET
2292
3.41k
      uint8_t access;
2293
3.41k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2294
3.41k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2295
3.41k
      MI->ac_idx++;
2296
3.41k
#endif
2297
3.41k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG_MRS;
2298
3.41k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Val;
2299
3.41k
      MI->flat_insn->detail->arm64.op_count++;
2300
3.41k
    }
2301
3.41k
  }
2302
3.74k
}
2303
2304
static void printSystemPStateField(MCInst *MI, unsigned OpNum, SStream *O)
2305
413
{
2306
413
  unsigned Val = (unsigned)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2307
2308
413
  const PState *PState = lookupPStateByEncoding(Val);
2309
2310
413
  if (PState) {
2311
413
    SStream_concat0(O, PState->Name);
2312
2313
413
    if (MI->csh->detail) {
2314
413
#ifndef CAPSTONE_DIET
2315
413
      uint8_t access;
2316
413
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2317
413
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2318
413
      MI->ac_idx++;
2319
413
#endif
2320
413
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_PSTATE;
2321
413
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].pstate = Val;
2322
413
      MI->flat_insn->detail->arm64.op_count++;
2323
413
    }
2324
413
  } 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
413
}
2342
2343
static void printSIMDType10Operand(MCInst *MI, unsigned OpNum, SStream *O)
2344
1.41k
{
2345
1.41k
  uint8_t RawVal = (uint8_t)MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2346
1.41k
  uint64_t Val = AArch64_AM_decodeAdvSIMDModImmType10(RawVal);
2347
2348
1.41k
  SStream_concat(O, "#%#016llx", Val);
2349
2350
1.41k
  if (MI->csh->detail) {
2351
1.41k
#ifndef CAPSTONE_DIET
2352
1.41k
    unsigned char access;
2353
2354
1.41k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2355
1.41k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2356
1.41k
    MI->ac_idx++;
2357
1.41k
#endif
2358
1.41k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
2359
1.41k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
2360
1.41k
    MI->flat_insn->detail->arm64.op_count++;
2361
1.41k
  }
2362
1.41k
}
2363
2364
static void printComplexRotationOp(MCInst *MI, unsigned OpNum, SStream *O, int64_t Angle, int64_t Remainder)
2365
2.33k
{
2366
2.33k
  unsigned int Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2367
2.33k
  printInt64Bang(O, (Val * Angle) + Remainder);
2368
2.33k
  op_addImm(MI, (Val * Angle) + Remainder);
2369
2.33k
}
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
401
{
2398
401
  MCOperand *RegOp = MCInst_getOperand(MI, OpNum);
2399
    // assert(MCOperand_isReg(RegOp) && "Unexpected operand type!");
2400
401
  unsigned Reg = MCOperand_getReg(RegOp);
2401
2402
401
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2403
401
  const char *sizeStr = "";
2404
401
    switch (EltSize) {
2405
401
    case 0:
2406
401
    sizeStr = "";
2407
401
      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
401
    }
2427
401
  SStream_concat0(O, sizeStr);
2428
2429
401
  if (MI->csh->detail) {
2430
401
#ifndef CAPSTONE_DIET
2431
401
    uint8_t access;
2432
2433
401
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2434
401
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2435
401
    MI->ac_idx++;
2436
401
#endif
2437
2438
401
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2439
401
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2440
401
    MI->flat_insn->detail->arm64.op_count++;
2441
401
  }
2442
401
}
2443
2444
static void printMatrixIndex(MCInst *MI, unsigned OpNum, SStream *O)
2445
5.77k
{
2446
5.77k
  int64_t imm = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2447
5.77k
  printInt64(O, imm);
2448
2449
5.77k
  if (MI->csh->detail) {
2450
5.77k
    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
5.77k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count-1].sme_index.disp = imm;
2453
5.77k
    }
2454
5.77k
  }
2455
5.77k
}
2456
2457
static void printMatrixTile(MCInst *MI, unsigned OpNum, SStream *O)
2458
1.93k
{
2459
1.93k
  MCOperand *RegOp = MCInst_getOperand(MI, OpNum);
2460
    // assert(MCOperand_isReg(RegOp) && "Unexpected operand type!");
2461
1.93k
  unsigned Reg = MCOperand_getReg(RegOp);
2462
1.93k
    SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2463
2464
1.93k
  if (MI->csh->detail) {
2465
1.93k
#ifndef CAPSTONE_DIET
2466
1.93k
    uint8_t access;
2467
2468
1.93k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2469
1.93k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2470
1.93k
    MI->ac_idx++;
2471
1.93k
#endif
2472
2473
1.93k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2474
1.93k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2475
1.93k
    MI->flat_insn->detail->arm64.op_count++;
2476
1.93k
  }
2477
1.93k
}
2478
2479
static void printMatrixTileVector(MCInst *MI, unsigned OpNum, SStream *O, bool IsVertical)
2480
4.82k
{
2481
4.82k
  MCOperand *RegOp = MCInst_getOperand(MI, OpNum);
2482
    // assert(MCOperand_isReg(RegOp) && "Unexpected operand type!");
2483
4.82k
  unsigned Reg = MCOperand_getReg(RegOp);
2484
4.82k
#ifndef CAPSTONE_DIET
2485
4.82k
  const char *RegName = getRegisterName(Reg, AArch64_NoRegAltName);
2486
2487
4.82k
  const size_t strLn = strlen(RegName);
2488
  // +2 for extra chars, + 1 for null char \0
2489
4.82k
  char *RegNameNew = cs_mem_malloc(sizeof(char) * (strLn + 2 + 1));
2490
4.82k
  int index = 0, i;
2491
38.7k
  for (i = 0; i < (strLn + 2); i++){
2492
33.8k
    if(RegName[i] != '.'){
2493
29.0k
      RegNameNew[index] = RegName[i];
2494
29.0k
      index++;
2495
29.0k
    }
2496
4.82k
    else{
2497
4.82k
      RegNameNew[index] = IsVertical ? 'v' : 'h';
2498
4.82k
      RegNameNew[index + 1] = '.';
2499
4.82k
      index += 2;
2500
4.82k
    }
2501
33.8k
  }
2502
4.82k
  SStream_concat0(O, RegNameNew);
2503
4.82k
#endif
2504
2505
4.82k
  if (MI->csh->detail) {
2506
4.82k
#ifndef CAPSTONE_DIET
2507
4.82k
    uint8_t access;
2508
2509
4.82k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2510
4.82k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2511
4.82k
    MI->ac_idx++;
2512
4.82k
#endif
2513
2514
4.82k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2515
4.82k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2516
4.82k
    MI->flat_insn->detail->arm64.op_count++;
2517
4.82k
  }
2518
4.82k
#ifndef CAPSTONE_DIET
2519
4.82k
  cs_mem_free(RegNameNew);
2520
4.82k
#endif
2521
4.82k
}
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
358
static void printMatrixTileList(MCInst *MI, unsigned OpNum, SStream *O){
2529
358
  unsigned MaxRegs = 8;
2530
358
  unsigned RegMask = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2531
2532
358
  unsigned NumRegs = 0, I;
2533
3.22k
  for (I = 0; I < MaxRegs; ++I)
2534
2.86k
    if ((RegMask & (1 << I)) != 0)
2535
964
      ++NumRegs;
2536
2537
358
  SStream_concat0(O, "{");
2538
358
  unsigned Printed = 0, J;
2539
3.22k
  for (J = 0; J < MaxRegs; ++J) {
2540
2.86k
    unsigned Reg = RegMask & (1 << J);
2541
2.86k
    if (Reg == 0)
2542
1.90k
      continue;
2543
964
    SStream_concat0(O, getRegisterName(MatrixZADRegisterTable[J], AArch64_NoRegAltName));
2544
2545
964
    if (MI->csh->detail) {
2546
964
#ifndef CAPSTONE_DIET
2547
964
      uint8_t access;
2548
2549
964
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2550
964
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2551
964
      MI->ac_idx++;
2552
964
#endif
2553
2554
964
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2555
964
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = MatrixZADRegisterTable[J];
2556
964
      MI->flat_insn->detail->arm64.op_count++;
2557
964
    }
2558
2559
964
    if (Printed + 1 != NumRegs)
2560
612
      SStream_concat0(O, ", ");
2561
964
    ++Printed;
2562
964
  }
2563
358
  SStream_concat0(O, "}");
2564
358
}
2565
2566
static void printSVEPattern(MCInst *MI, unsigned OpNum, SStream *O)
2567
3.72k
{
2568
3.72k
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2569
2570
3.72k
  const SVEPREDPAT *Pat = lookupSVEPREDPATByEncoding(Val);
2571
3.72k
  if (Pat)
2572
2.65k
    SStream_concat0(O, Pat->Name);
2573
1.06k
  else
2574
1.06k
    printUInt32Bang(O, Val);
2575
3.72k
}
2576
2577
// default suffix = 0
2578
static void printSVERegOp(MCInst *MI, unsigned OpNum, SStream *O, char suffix)
2579
144k
{
2580
144k
  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
144k
  Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
2597
2598
144k
  if (MI->csh->detail) {
2599
144k
#ifndef CAPSTONE_DIET
2600
144k
      uint8_t access;
2601
2602
144k
      access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2603
144k
      MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2604
144k
      MI->ac_idx++;
2605
144k
#endif
2606
144k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2607
144k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2608
144k
    MI->flat_insn->detail->arm64.op_count++;
2609
144k
  }
2610
2611
144k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2612
2613
144k
  if (suffix != '\0')
2614
95.2k
    SStream_concat(O, ".%c", suffix);
2615
144k
}
2616
2617
static void printImmSVE16(int16_t Val, SStream *O)
2618
948
{
2619
948
  printUInt32Bang(O, Val);
2620
948
}
2621
2622
static void printImmSVE32(int32_t Val, SStream *O)
2623
1.98k
{
2624
1.98k
  printUInt32Bang(O, Val);
2625
1.98k
}
2626
2627
static void printImmSVE64(int64_t Val, SStream *O)
2628
1.02k
{
2629
1.02k
  printUInt64Bang(O, Val);
2630
1.02k
}
2631
2632
static void printImm8OptLsl32(MCInst *MI, unsigned OpNum, SStream *O)
2633
2.04k
{
2634
2.04k
  unsigned UnscaledVal = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2635
2.04k
  unsigned Shift = MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1));
2636
2.04k
  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
2.04k
  if ((UnscaledVal == 0) && (AArch64_AM_getShiftValue(Shift) != 0)) {
2643
61
    printUInt32Bang(O, UnscaledVal);
2644
61
    printShifter(MI, OpNum + 1, O);
2645
61
    return;
2646
61
  }
2647
2648
1.98k
  Val = UnscaledVal * (1 << AArch64_AM_getShiftValue(Shift));
2649
1.98k
  printImmSVE32(Val, O);
2650
1.98k
}
2651
2652
static void printImm8OptLsl64(MCInst *MI, unsigned OpNum, SStream *O)
2653
761
{
2654
761
  unsigned UnscaledVal = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2655
761
  unsigned Shift = MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1));
2656
761
  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
761
  if ((UnscaledVal == 0) && (AArch64_AM_getShiftValue(Shift) != 0)) {
2663
291
    printUInt32Bang(O, UnscaledVal);
2664
291
    printShifter(MI, OpNum + 1, O);
2665
291
    return;
2666
291
  }
2667
2668
470
  Val = UnscaledVal * (1 << AArch64_AM_getShiftValue(Shift));
2669
470
  printImmSVE64(Val, O);
2670
470
}
2671
2672
static void printSVELogicalImm16(MCInst *MI, unsigned OpNum, SStream *O)
2673
540
{
2674
540
  uint64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2675
540
  uint64_t PrintVal = AArch64_AM_decodeLogicalImmediate(Val, 64);
2676
2677
  // Prefer the default format for 16bit values, hex otherwise.
2678
540
  printImmSVE16(PrintVal, O);
2679
540
}
2680
2681
static void printSVELogicalImm32(MCInst *MI, unsigned OpNum, SStream *O)
2682
893
{
2683
893
  uint64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2684
893
  uint64_t PrintVal = AArch64_AM_decodeLogicalImmediate(Val, 64);
2685
2686
  // Prefer the default format for 16bit values, hex otherwise.
2687
893
  if ((uint16_t)PrintVal == (uint32_t)PrintVal)
2688
408
    printImmSVE16(PrintVal, O);
2689
485
  else
2690
485
    printUInt64Bang(O, PrintVal);
2691
893
}
2692
2693
static void printSVELogicalImm64(MCInst *MI, unsigned OpNum, SStream *O)
2694
550
{
2695
550
  uint64_t Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2696
550
  uint64_t PrintVal = AArch64_AM_decodeLogicalImmediate(Val, 64);
2697
2698
550
  printImmSVE64(PrintVal, O);
2699
550
}
2700
2701
static void printZPRasFPR(MCInst *MI, unsigned OpNum, SStream *O, int Width)
2702
2.45k
{
2703
2.45k
  unsigned int Base, Reg;
2704
2705
2.45k
  switch (Width) {
2706
0
    default: // llvm_unreachable("Unsupported width");
2707
170
    case 8:   Base = AArch64_B0; break;
2708
546
    case 16:  Base = AArch64_H0; break;
2709
834
    case 32:  Base = AArch64_S0; break;
2710
836
    case 64:  Base = AArch64_D0; break;
2711
71
    case 128: Base = AArch64_Q0; break;
2712
2.45k
  }
2713
2714
2.45k
  Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum)) - AArch64_Z0 + Base;
2715
2716
2.45k
  SStream_concat0(O, getRegisterName(Reg, AArch64_NoRegAltName));
2717
2718
2.45k
  if (MI->csh->detail) {
2719
2.45k
#ifndef CAPSTONE_DIET
2720
2.45k
    uint8_t access;
2721
2722
2.45k
    access = get_op_access(MI->csh, MCInst_getOpcode(MI), MI->ac_idx);
2723
2.45k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].access = access;
2724
2.45k
    MI->ac_idx++;
2725
2.45k
#endif
2726
2.45k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_REG;
2727
2.45k
    MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg;
2728
2.45k
    MI->flat_insn->detail->arm64.op_count++;
2729
2.45k
  }
2730
2.45k
}
2731
2732
static void printExactFPImm(MCInst *MI, unsigned OpNum, SStream *O, unsigned ImmIs0, unsigned ImmIs1)
2733
442
{
2734
442
  const ExactFPImm *Imm0Desc = lookupExactFPImmByEnum(ImmIs0);
2735
442
  const ExactFPImm *Imm1Desc = lookupExactFPImmByEnum(ImmIs1);
2736
442
  unsigned Val = MCOperand_getImm(MCInst_getOperand(MI, OpNum));
2737
2738
442
  SStream_concat0(O, Val ? Imm1Desc->Repr : Imm0Desc->Repr);
2739
442
}
2740
2741
static void printGPR64as32(MCInst *MI, unsigned OpNum, SStream *O)
2742
5.10k
{
2743
5.10k
  unsigned int Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
2744
2745
5.10k
  SStream_concat0(O, getRegisterName(getWRegFromXReg(Reg), AArch64_NoRegAltName));
2746
5.10k
}
2747
2748
static void printGPR64x8(MCInst *MI, unsigned OpNum, SStream *O) 
2749
677
{
2750
677
    unsigned int Reg = MCOperand_getReg(MCInst_getOperand(MI, OpNum));
2751
2752
677
    SStream_concat0(O, getRegisterName(MCRegisterInfo_getSubReg(MI->MRI, Reg, AArch64_x8sub_0), AArch64_NoRegAltName));
2753
677
}
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
320k
{
2761
320k
  if (((cs_struct *)handle)->detail != CS_OPT_ON)
2762
0
    return;
2763
2764
320k
  if (mci->csh->detail) {
2765
320k
    unsigned opcode = MCInst_getOpcode(mci);
2766
2767
320k
    switch (opcode) {
2768
257k
      default:
2769
257k
        break;
2770
257k
      case AArch64_LD1Fourv16b_POST:
2771
273
      case AArch64_LD1Fourv1d_POST:
2772
329
      case AArch64_LD1Fourv2d_POST:
2773
584
      case AArch64_LD1Fourv2s_POST:
2774
728
      case AArch64_LD1Fourv4h_POST:
2775
1.11k
      case AArch64_LD1Fourv4s_POST:
2776
1.39k
      case AArch64_LD1Fourv8b_POST:
2777
2.13k
      case AArch64_LD1Fourv8h_POST:
2778
2.24k
      case AArch64_LD1Onev16b_POST:
2779
2.45k
      case AArch64_LD1Onev1d_POST:
2780
2.74k
      case AArch64_LD1Onev2d_POST:
2781
2.91k
      case AArch64_LD1Onev2s_POST:
2782
2.96k
      case AArch64_LD1Onev4h_POST:
2783
3.10k
      case AArch64_LD1Onev4s_POST:
2784
3.20k
      case AArch64_LD1Onev8b_POST:
2785
3.48k
      case AArch64_LD1Onev8h_POST:
2786
3.51k
      case AArch64_LD1Rv16b_POST:
2787
3.53k
      case AArch64_LD1Rv1d_POST:
2788
3.75k
      case AArch64_LD1Rv2d_POST:
2789
3.78k
      case AArch64_LD1Rv2s_POST:
2790
3.85k
      case AArch64_LD1Rv4h_POST:
2791
4.37k
      case AArch64_LD1Rv4s_POST:
2792
4.41k
      case AArch64_LD1Rv8b_POST:
2793
4.48k
      case AArch64_LD1Rv8h_POST:
2794
4.73k
      case AArch64_LD1Threev16b_POST:
2795
4.78k
      case AArch64_LD1Threev1d_POST:
2796
4.87k
      case AArch64_LD1Threev2d_POST:
2797
4.97k
      case AArch64_LD1Threev2s_POST:
2798
5.02k
      case AArch64_LD1Threev4h_POST:
2799
5.44k
      case AArch64_LD1Threev4s_POST:
2800
5.90k
      case AArch64_LD1Threev8b_POST:
2801
6.20k
      case AArch64_LD1Threev8h_POST:
2802
6.42k
      case AArch64_LD1Twov16b_POST:
2803
6.62k
      case AArch64_LD1Twov1d_POST:
2804
6.93k
      case AArch64_LD1Twov2d_POST:
2805
6.95k
      case AArch64_LD1Twov2s_POST:
2806
7.12k
      case AArch64_LD1Twov4h_POST:
2807
7.31k
      case AArch64_LD1Twov4s_POST:
2808
7.55k
      case AArch64_LD1Twov8b_POST:
2809
7.59k
      case AArch64_LD1Twov8h_POST:
2810
7.79k
      case AArch64_LD1i16_POST:
2811
8.51k
      case AArch64_LD1i32_POST:
2812
9.69k
      case AArch64_LD1i64_POST:
2813
10.5k
      case AArch64_LD1i8_POST:
2814
10.8k
      case AArch64_LD2Rv16b_POST:
2815
11.0k
      case AArch64_LD2Rv1d_POST:
2816
11.4k
      case AArch64_LD2Rv2d_POST:
2817
11.6k
      case AArch64_LD2Rv2s_POST:
2818
12.4k
      case AArch64_LD2Rv4h_POST:
2819
12.6k
      case AArch64_LD2Rv4s_POST:
2820
12.6k
      case AArch64_LD2Rv8b_POST:
2821
12.7k
      case AArch64_LD2Rv8h_POST:
2822
12.9k
      case AArch64_LD2Twov16b_POST:
2823
13.0k
      case AArch64_LD2Twov2d_POST:
2824
13.0k
      case AArch64_LD2Twov2s_POST:
2825
13.2k
      case AArch64_LD2Twov4h_POST:
2826
13.4k
      case AArch64_LD2Twov4s_POST:
2827
13.7k
      case AArch64_LD2Twov8b_POST:
2828
13.8k
      case AArch64_LD2Twov8h_POST:
2829
14.0k
      case AArch64_LD2i16_POST:
2830
14.4k
      case AArch64_LD2i32_POST:
2831
16.1k
      case AArch64_LD2i64_POST:
2832
17.0k
      case AArch64_LD2i8_POST:
2833
17.2k
      case AArch64_LD3Rv16b_POST:
2834
17.3k
      case AArch64_LD3Rv1d_POST:
2835
17.7k
      case AArch64_LD3Rv2d_POST:
2836
17.8k
      case AArch64_LD3Rv2s_POST:
2837
18.0k
      case AArch64_LD3Rv4h_POST:
2838
18.4k
      case AArch64_LD3Rv4s_POST:
2839
18.4k
      case AArch64_LD3Rv8b_POST:
2840
18.8k
      case AArch64_LD3Rv8h_POST:
2841
18.9k
      case AArch64_LD3Threev16b_POST:
2842
19.3k
      case AArch64_LD3Threev2d_POST:
2843
19.4k
      case AArch64_LD3Threev2s_POST:
2844
19.6k
      case AArch64_LD3Threev4h_POST:
2845
19.8k
      case AArch64_LD3Threev4s_POST:
2846
19.9k
      case AArch64_LD3Threev8b_POST:
2847
20.2k
      case AArch64_LD3Threev8h_POST:
2848
20.8k
      case AArch64_LD3i16_POST:
2849
21.2k
      case AArch64_LD3i32_POST:
2850
22.0k
      case AArch64_LD3i64_POST:
2851
22.4k
      case AArch64_LD3i8_POST:
2852
22.5k
      case AArch64_LD4Fourv16b_POST:
2853
22.6k
      case AArch64_LD4Fourv2d_POST:
2854
22.8k
      case AArch64_LD4Fourv2s_POST:
2855
23.1k
      case AArch64_LD4Fourv4h_POST:
2856
23.3k
      case AArch64_LD4Fourv4s_POST:
2857
23.4k
      case AArch64_LD4Fourv8b_POST:
2858
23.6k
      case AArch64_LD4Fourv8h_POST:
2859
23.6k
      case AArch64_LD4Rv16b_POST:
2860
23.7k
      case AArch64_LD4Rv1d_POST:
2861
23.8k
      case AArch64_LD4Rv2d_POST:
2862
24.7k
      case AArch64_LD4Rv2s_POST:
2863
24.8k
      case AArch64_LD4Rv4h_POST:
2864
25.1k
      case AArch64_LD4Rv4s_POST:
2865
25.3k
      case AArch64_LD4Rv8b_POST:
2866
25.7k
      case AArch64_LD4Rv8h_POST:
2867
26.3k
      case AArch64_LD4i16_POST:
2868
26.6k
      case AArch64_LD4i32_POST:
2869
27.0k
      case AArch64_LD4i64_POST:
2870
27.8k
      case AArch64_LD4i8_POST:
2871
27.8k
      case AArch64_LDRBBpost:
2872
27.9k
      case AArch64_LDRBpost:
2873
28.0k
      case AArch64_LDRDpost:
2874
28.4k
      case AArch64_LDRHHpost:
2875
28.6k
      case AArch64_LDRHpost:
2876
29.3k
      case AArch64_LDRQpost:
2877
29.3k
      case AArch64_LDPDpost:
2878
29.6k
      case AArch64_LDPQpost:
2879
29.7k
      case AArch64_LDPSWpost:
2880
30.1k
      case AArch64_LDPSpost:
2881
30.7k
      case AArch64_LDPWpost:
2882
30.8k
      case AArch64_LDPXpost:
2883
30.8k
      case AArch64_ST1Fourv16b_POST:
2884
31.1k
      case AArch64_ST1Fourv1d_POST:
2885
31.4k
      case AArch64_ST1Fourv2d_POST:
2886
31.5k
      case AArch64_ST1Fourv2s_POST:
2887
31.7k
      case AArch64_ST1Fourv4h_POST:
2888
31.7k
      case AArch64_ST1Fourv4s_POST:
2889
31.8k
      case AArch64_ST1Fourv8b_POST:
2890
32.7k
      case AArch64_ST1Fourv8h_POST:
2891
32.8k
      case AArch64_ST1Onev16b_POST:
2892
33.0k
      case AArch64_ST1Onev1d_POST:
2893
33.1k
      case AArch64_ST1Onev2d_POST:
2894
33.2k
      case AArch64_ST1Onev2s_POST:
2895
33.2k
      case AArch64_ST1Onev4h_POST:
2896
33.3k
      case AArch64_ST1Onev4s_POST:
2897
33.4k
      case AArch64_ST1Onev8b_POST:
2898
33.5k
      case AArch64_ST1Onev8h_POST:
2899
33.5k
      case AArch64_ST1Threev16b_POST:
2900
33.6k
      case AArch64_ST1Threev1d_POST:
2901
33.6k
      case AArch64_ST1Threev2d_POST:
2902
33.9k
      case AArch64_ST1Threev2s_POST:
2903
34.2k
      case AArch64_ST1Threev4h_POST:
2904
34.2k
      case AArch64_ST1Threev4s_POST:
2905
34.4k
      case AArch64_ST1Threev8b_POST:
2906
34.5k
      case AArch64_ST1Threev8h_POST:
2907
34.6k
      case AArch64_ST1Twov16b_POST:
2908
34.8k
      case AArch64_ST1Twov1d_POST:
2909
34.9k
      case AArch64_ST1Twov2d_POST:
2910
35.3k
      case AArch64_ST1Twov2s_POST:
2911
35.3k
      case AArch64_ST1Twov4h_POST:
2912
35.4k
      case AArch64_ST1Twov4s_POST:
2913
35.5k
      case AArch64_ST1Twov8b_POST:
2914
35.6k
      case AArch64_ST1Twov8h_POST:
2915
35.9k
      case AArch64_ST1i16_POST:
2916
36.1k
      case AArch64_ST1i32_POST:
2917
36.6k
      case AArch64_ST1i64_POST:
2918
37.1k
      case AArch64_ST1i8_POST:
2919
37.3k
      case AArch64_ST2GPostIndex:
2920
37.8k
      case AArch64_ST2Twov16b_POST:
2921
37.8k
      case AArch64_ST2Twov2d_POST:
2922
37.9k
      case AArch64_ST2Twov2s_POST:
2923
38.0k
      case AArch64_ST2Twov4h_POST:
2924
38.1k
      case AArch64_ST2Twov4s_POST:
2925
38.3k
      case AArch64_ST2Twov8b_POST:
2926
38.5k
      case AArch64_ST2Twov8h_POST:
2927
38.8k
      case AArch64_ST2i16_POST:
2928
39.0k
      case AArch64_ST2i32_POST:
2929
39.2k
      case AArch64_ST2i64_POST:
2930
39.5k
      case AArch64_ST2i8_POST:
2931
39.6k
      case AArch64_ST3Threev16b_POST:
2932
39.9k
      case AArch64_ST3Threev2d_POST:
2933
40.5k
      case AArch64_ST3Threev2s_POST:
2934
40.6k
      case AArch64_ST3Threev4h_POST:
2935
40.9k
      case AArch64_ST3Threev4s_POST:
2936
40.9k
      case AArch64_ST3Threev8b_POST:
2937
40.9k
      case AArch64_ST3Threev8h_POST:
2938
41.7k
      case AArch64_ST3i16_POST:
2939
42.3k
      case AArch64_ST3i32_POST:
2940
42.5k
      case AArch64_ST3i64_POST:
2941
42.9k
      case AArch64_ST3i8_POST:
2942
44.0k
      case AArch64_ST4Fourv16b_POST:
2943
44.1k
      case AArch64_ST4Fourv2d_POST:
2944
44.1k
      case AArch64_ST4Fourv2s_POST:
2945
44.2k
      case AArch64_ST4Fourv4h_POST:
2946
44.2k
      case AArch64_ST4Fourv4s_POST:
2947
44.3k
      case AArch64_ST4Fourv8b_POST:
2948
45.5k
      case AArch64_ST4Fourv8h_POST:
2949
45.6k
      case AArch64_ST4i16_POST:
2950
46.0k
      case AArch64_ST4i32_POST:
2951
46.2k
      case AArch64_ST4i64_POST:
2952
46.6k
      case AArch64_ST4i8_POST:
2953
47.1k
      case AArch64_STPDpost:
2954
47.3k
      case AArch64_STPQpost:
2955
47.9k
      case AArch64_STPSpost:
2956
48.5k
      case AArch64_STPWpost:
2957
49.0k
      case AArch64_STPXpost:
2958
49.0k
      case AArch64_STRBBpost:
2959
49.1k
      case AArch64_STRBpost:
2960
49.2k
      case AArch64_STRDpost:
2961
49.3k
      case AArch64_STRHHpost:
2962
49.3k
      case AArch64_STRHpost:
2963
49.6k
      case AArch64_STRQpost:
2964
49.7k
      case AArch64_STRSpost:
2965
49.7k
      case AArch64_STRWpost:
2966
49.8k
      case AArch64_STRXpost:
2967
49.9k
      case AArch64_STZ2GPostIndex:
2968
49.9k
      case AArch64_STZGPostIndex:
2969
50.0k
      case AArch64_STGPostIndex:
2970
50.0k
      case AArch64_STGPpost:
2971
50.2k
      case AArch64_LDRSBWpost:
2972
50.5k
      case AArch64_LDRSBXpost:
2973
50.6k
      case AArch64_LDRSHWpost:
2974
51.0k
      case AArch64_LDRSHXpost:
2975
51.1k
      case AArch64_LDRSWpost:
2976
51.2k
      case AArch64_LDRSpost:
2977
51.3k
      case AArch64_LDRWpost:
2978
51.6k
      case AArch64_LDRXpost:
2979
51.6k
        flat_insn->detail->arm64.writeback = true;
2980
51.6k
          flat_insn->detail->arm64.post_index = true;
2981
51.6k
        break;
2982
449
      case AArch64_LDRAAwriteback:
2983
589
      case AArch64_LDRABwriteback:
2984
965
      case AArch64_ST2GPreIndex:
2985
1.20k
      case AArch64_LDPDpre:
2986
1.43k
      case AArch64_LDPQpre:
2987
1.99k
      case AArch64_LDPSWpre:
2988
2.12k
      case AArch64_LDPSpre:
2989
2.22k
      case AArch64_LDPWpre:
2990
2.74k
      case AArch64_LDPXpre:
2991
2.89k
      case AArch64_LDRBBpre:
2992
3.26k
      case AArch64_LDRBpre:
2993
3.51k
      case AArch64_LDRDpre:
2994
3.59k
      case AArch64_LDRHHpre:
2995
3.87k
      case AArch64_LDRHpre:
2996
4.01k
      case AArch64_LDRQpre:
2997
4.32k
      case AArch64_LDRSBWpre:
2998
4.38k
      case AArch64_LDRSBXpre:
2999
4.67k
      case AArch64_LDRSHWpre:
3000
4.95k
      case AArch64_LDRSHXpre:
3001
5.03k
      case AArch64_LDRSWpre:
3002
5.22k
      case AArch64_LDRSpre:
3003
5.27k
      case AArch64_LDRWpre:
3004
5.38k
      case AArch64_LDRXpre:
3005
6.02k
      case AArch64_STGPreIndex:
3006
6.48k
      case AArch64_STPDpre:
3007
7.07k
      case AArch64_STPQpre:
3008
7.85k
      case AArch64_STPSpre:
3009
7.91k
      case AArch64_STPWpre:
3010
8.61k
      case AArch64_STPXpre:
3011
9.05k
      case AArch64_STRBBpre:
3012
9.27k
      case AArch64_STRBpre:
3013
9.57k
      case AArch64_STRDpre:
3014
9.77k
      case AArch64_STRHHpre:
3015
9.98k
      case AArch64_STRHpre:
3016
10.1k
      case AArch64_STRQpre:
3017
10.3k
      case AArch64_STRSpre:
3018
10.4k
      case AArch64_STRWpre:
3019
10.5k
      case AArch64_STRXpre:
3020
10.9k
      case AArch64_STZ2GPreIndex:
3021
11.1k
      case AArch64_STZGPreIndex:
3022
11.1k
      case AArch64_STGPpre:
3023
        flat_insn->detail->arm64.writeback = true;
3024
11.1k
        break;
3025
320k
    }
3026
320k
  }
3027
320k
}
3028
3029
#endif