Coverage Report

Created: 2026-09-28 06:34

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