Coverage Report

Created: 2026-02-26 07:11

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