Coverage Report

Created: 2026-07-16 06:55

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