Coverage Report

Created: 2026-04-29 06:06

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