Coverage Report

Created: 2025-10-10 06:20

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