Coverage Report

Created: 2026-04-12 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonenext/arch/ARM/ARMInstPrinter.c
Line
Count
Source
1
/* Capstone Disassembly Engine, http://www.capstone-engine.org */
2
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2022, */
3
/*    Rot127 <unisono@quyllur.org> 2022-2023 */
4
/* Automatically translated source file from LLVM. */
5
6
/* LLVM-commit: <commit> */
7
/* LLVM-tag: <tag> */
8
9
/* Only small edits allowed. */
10
/* For multiple similar edits, please create a Patch for the translator. */
11
12
/* Capstone's C++ file translator: */
13
/* https://github.com/capstone-engine/capstone/tree/next/suite/auto-sync */
14
15
//===-- ARMInstPrinter.cpp - Convert ARM MCInst to assembly syntax --------===//
16
//
17
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
18
// See https://llvm.org/LICENSE.txt for license information.
19
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
20
//
21
//===----------------------------------------------------------------------===//
22
//
23
// This class prints an ARM MCInst to a .s file.
24
//
25
//===----------------------------------------------------------------------===//
26
27
#include <capstone/arm.h>
28
29
#include <capstone/platform.h>
30
31
#include "../../Mapping.h"
32
#include "../../MCInst.h"
33
#include "../../MCInstPrinter.h"
34
#include "../../MCRegisterInfo.h"
35
#include "../../SStream.h"
36
37
#include "ARMAddressingModes.h"
38
#include "ARMBaseInfo.h"
39
#include "ARMDisassemblerExtension.h"
40
#include "ARMInstPrinter.h"
41
#include "ARMLinkage.h"
42
#include "ARMMapping.h"
43
44
#define GET_BANKEDREG_IMPL
45
#include "ARMGenSystemRegister.inc"
46
47
58.3k
#define CONCAT(a, b) CONCAT_(a, b)
48
58.3k
#define CONCAT_(a, b) a##_##b
49
50
#define DEBUG_TYPE "asm-printer"
51
52
// Static function declarations. These are functions which have the same identifiers
53
// over all architectures. Therefor they need to be static.
54
#ifndef CAPSTONE_DIET
55
static void printCustomAliasOperand(MCInst *MI, uint64_t Address,
56
            unsigned OpIdx, unsigned PrintMethodIdx,
57
            SStream *O);
58
#endif
59
static const char *getRegisterName(unsigned RegNo, unsigned AltIdx);
60
61
/// translateShiftImm - Convert shift immediate from 0-31 to 1-32 for printing.
62
///
63
/// getSORegOffset returns an integer from 0-31, representing '32' as 0.
64
unsigned translateShiftImm(unsigned imm)
65
41.5k
{
66
  // lsr #32 and asr #32 exist, but should be encoded as a 0.
67
41.5k
  CS_ASSERT((imm & ~0x1f) == 0 && "Invalid shift encoding");
68
69
41.5k
  if (imm == 0)
70
1.92k
    return 32;
71
39.6k
  return imm;
72
41.5k
}
73
74
/// Prints the shift value with an immediate value.
75
static inline void printRegImmShift(MCInst *MI, SStream *O,
76
            ARM_AM_ShiftOpc ShOpc, unsigned ShImm,
77
            bool UseMarkup)
78
14.7k
{
79
14.7k
  ARM_add_cs_detail_2(MI, ARM_OP_GROUP_RegImmShift, -1, ShOpc, ShImm);
80
14.7k
  if (ShOpc == ARM_AM_no_shift || (ShOpc == ARM_AM_lsl && !ShImm))
81
570
    return;
82
14.2k
  SStream_concat0(O, ", ");
83
84
14.2k
  CS_ASSERT(!(ShOpc == ARM_AM_ror && !ShImm) && "Cannot have ror #0");
85
14.2k
  SStream_concat0(O, ARM_AM_getShiftOpcStr(ShOpc));
86
87
14.2k
  if (ShOpc != ARM_AM_rrx) {
88
13.5k
    SStream_concat0(O, " ");
89
13.5k
    if (getUseMarkup())
90
0
      SStream_concat0(O, "<imm:");
91
13.5k
    SStream_concat(O, "%s%d", "#", translateShiftImm(ShImm));
92
13.5k
    if (getUseMarkup())
93
0
      SStream_concat0(O, ">");
94
13.5k
  }
95
14.2k
}
96
97
static void printPredicateOperand(MCInst *MI, unsigned OpNum, SStream *O)
98
558k
{
99
558k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_PredicateOperand, OpNum);
100
558k
  ARMCC_CondCodes CC = (ARMCC_CondCodes)MCOperand_getImm(
101
558k
    MCInst_getOperand(MI, (OpNum)));
102
  // Handle the undefined 15 CC value here for printing so we don't abort().
103
558k
  if ((unsigned)CC == 15)
104
966
    SStream_concat0(O, "<und>");
105
557k
  else if (CC != ARMCC_AL)
106
82.6k
    SStream_concat0(O, ARMCondCodeToString(CC));
107
558k
}
108
109
static void printRegName(SStream *OS, unsigned RegNo)
110
1.29M
{
111
1.29M
  SStream_concat(OS, "%s%s", markup("<reg:"),
112
1.29M
           getRegisterName(RegNo, ARM_NoRegAltName));
113
1.29M
  SStream_concat0(OS, markup(">"));
114
1.29M
}
115
116
static inline void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
117
1.06M
{
118
1.06M
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_Operand, OpNo);
119
1.06M
  MCOperand *Op = MCInst_getOperand(MI, (OpNo));
120
1.06M
  if (MCOperand_isReg(Op)) {
121
863k
    unsigned Reg = MCOperand_getReg(Op);
122
863k
    printRegName(O, Reg);
123
863k
  } else if (MCOperand_isImm(Op)) {
124
196k
    SStream_concat(O, "%s", markup("<imm:"));
125
196k
    SStream_concat1(O, '#');
126
196k
    printInt64(O, MCOperand_getImm(Op));
127
196k
    SStream_concat0(O, markup(">"));
128
196k
  } else {
129
0
    CS_ASSERT_RET(0 && "Expressions are not supported.");
130
0
  }
131
1.06M
}
132
133
static inline void printRegisterList(MCInst *MI, unsigned OpNum, SStream *O)
134
27.7k
{
135
27.7k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_RegisterList, OpNum);
136
27.7k
  if (MCInst_getOpcode(MI) != ARM_t2CLRM) {
137
27.7k
  }
138
139
27.7k
  SStream_concat0(O, "{");
140
174k
  for (unsigned i = OpNum, e = MCInst_getNumOperands(MI); i != e; ++i) {
141
146k
    if (i != OpNum)
142
118k
      SStream_concat0(O, ", ");
143
146k
    printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (i))));
144
146k
  }
145
27.7k
  SStream_concat0(O, "}");
146
27.7k
}
147
148
static inline void printSBitModifierOperand(MCInst *MI, unsigned OpNum,
149
              SStream *O)
150
172k
{
151
172k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_SBitModifierOperand, OpNum);
152
172k
  if (MCOperand_getReg(MCInst_getOperand(MI, (OpNum)))) {
153
155k
    SStream_concat0(O, "s");
154
155k
  }
155
172k
}
156
157
static inline void printOperandAddr(MCInst *MI, uint64_t Address,
158
            unsigned OpNum, SStream *O)
159
37.6k
{
160
37.6k
  MCOperand *Op = MCInst_getOperand(MI, (OpNum));
161
37.6k
  if (!MCOperand_isImm(Op) || !MI->csh->PrintBranchImmAsAddress ||
162
37.6k
      getUseMarkup()) {
163
0
    printOperand(MI, OpNum, O);
164
0
    return;
165
0
  }
166
37.6k
  int64_t Imm = MCOperand_getImm(Op);
167
  // For ARM instructions the PC offset is 8 bytes, for Thumb instructions it
168
  // is 4 bytes.
169
37.6k
  uint64_t Offset = ARM_getFeatureBits(MI->csh->mode, ARM_ModeThumb) ? 4 :
170
37.6k
                       8;
171
172
  // A Thumb instruction BLX(i) can be 16-bit aligned while targets Arm code
173
  // which is 32-bit aligned. The target address for the case is calculated as
174
  //   targetAddress = Align(PC,4) + imm32;
175
  // where
176
  //   Align(x, y) = y * (x DIV y);
177
37.6k
  if (MCInst_getOpcode(MI) == ARM_tBLXi)
178
203
    Address &= ~0x3;
179
180
37.6k
  uint64_t Target = Address + Imm + Offset;
181
182
37.6k
  Target &= 0xffffffff;
183
37.6k
  ARM_set_detail_op_imm(MI, OpNum, ARM_OP_IMM, Target);
184
37.6k
  printUInt64(O, Target);
185
37.6k
}
186
187
static inline void printThumbLdrLabelOperand(MCInst *MI, unsigned OpNum,
188
               SStream *O)
189
15.1k
{
190
15.1k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbLdrLabelOperand, OpNum);
191
15.1k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
192
15.1k
  if (MCOperand_isExpr(MO1)) {
193
    // MO1.getExpr()->print(O, &MAI);
194
0
    return;
195
0
  }
196
197
15.1k
  SStream_concat(O, "%s", markup("<mem:"));
198
15.1k
  SStream_concat0(O, "[pc, ");
199
200
15.1k
  int32_t OffImm = (int32_t)MCOperand_getImm(MO1);
201
202
  // Special value for #-0. All others are normal.
203
15.1k
  if (OffImm == INT32_MIN)
204
602
    OffImm = 0;
205
15.1k
  SStream_concat(O, "%s", markup("<imm:"));
206
15.1k
  printInt32Bang(O, OffImm);
207
15.1k
  SStream_concat0(O, markup(">"));
208
15.1k
  SStream_concat(O, "%s", "]");
209
15.1k
  SStream_concat0(O, markup(">"));
210
15.1k
}
211
212
// so_reg is a 4-operand unit corresponding to register forms of the A5.1
213
// "Addressing Mode 1 - Data-processing operands" forms.  This includes:
214
//    REG 0   0           - e.g. R5
215
//    REG REG 0,SH_OPC    - e.g. R5, ROR R3
216
//    REG 0   IMM,SH_OPC  - e.g. R5, LSL #3
217
static inline void printSORegRegOperand(MCInst *MI, unsigned OpNum, SStream *O)
218
2.79k
{
219
2.79k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_SORegRegOperand, OpNum);
220
2.79k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
221
2.79k
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
222
2.79k
  MCOperand *MO3 = MCInst_getOperand(MI, (OpNum + 2));
223
224
2.79k
  printRegName(O, MCOperand_getReg(MO1));
225
226
  // Print the shift opc.
227
2.79k
  ARM_AM_ShiftOpc ShOpc = ARM_AM_getSORegShOp(MCOperand_getImm(MO3));
228
2.79k
  SStream_concat(O, "%s", ", ");
229
2.79k
  SStream_concat0(O, ARM_AM_getShiftOpcStr(ShOpc));
230
2.79k
  if (ShOpc == ARM_AM_rrx)
231
0
    return;
232
233
2.79k
  SStream_concat0(O, " ");
234
235
2.79k
  printRegName(O, MCOperand_getReg(MO2));
236
2.79k
}
237
238
static inline void printSORegImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
239
6.35k
{
240
6.35k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_SORegImmOperand, OpNum);
241
6.35k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
242
6.35k
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
243
244
6.35k
  printRegName(O, MCOperand_getReg(MO1));
245
246
  // Print the shift opc.
247
6.35k
  printRegImmShift(MI, O, ARM_AM_getSORegShOp(MCOperand_getImm(MO2)),
248
6.35k
       ARM_AM_getSORegOffset(MCOperand_getImm(MO2)),
249
6.35k
       getUseMarkup());
250
6.35k
}
251
252
//===--------------------------------------------------------------------===//
253
// Addressing Mode #2
254
//===--------------------------------------------------------------------===//
255
256
static inline void printAM2PreOrOffsetIndexOp(MCInst *MI, unsigned Op,
257
                SStream *O)
258
3.64k
{
259
3.64k
  MCOperand *MO1 = MCInst_getOperand(MI, (Op));
260
3.64k
  MCOperand *MO2 = MCInst_getOperand(MI, (Op + 1));
261
3.64k
  MCOperand *MO3 = MCInst_getOperand(MI, (Op + 2));
262
263
3.64k
  SStream_concat(O, "%s", markup("<mem:"));
264
3.64k
  SStream_concat0(O, "[");
265
3.64k
  printRegName(O, MCOperand_getReg(MO1));
266
267
3.64k
  if (!MCOperand_getReg(MO2)) {
268
0
    if (ARM_AM_getAM2Offset(
269
0
          MCOperand_getImm(MO3))) { // Don't print +0.
270
0
      SStream_concat(
271
0
        O, "%s%s%s", ", ", markup("<imm:"), "#",
272
0
        ARM_AM_getAddrOpcStr(
273
0
          ARM_AM_getAM2Op(MCOperand_getImm(MO3))),
274
0
        ARM_AM_getAM2Offset(MCOperand_getImm(MO3)));
275
0
      SStream_concat0(O, markup(">"));
276
0
    }
277
0
    SStream_concat(O, "%s", "]");
278
0
    SStream_concat0(O, markup(">"));
279
0
    return;
280
0
  }
281
282
3.64k
  SStream_concat0(O, ", ");
283
3.64k
  SStream_concat0(O, ARM_AM_getAddrOpcStr(
284
3.64k
           ARM_AM_getAM2Op(MCOperand_getImm(MO3))));
285
3.64k
  printRegName(O, MCOperand_getReg(MO2));
286
287
3.64k
  printRegImmShift(MI, O, ARM_AM_getAM2ShiftOpc(MCOperand_getImm(MO3)),
288
3.64k
       ARM_AM_getAM2Offset(MCOperand_getImm(MO3)),
289
3.64k
       getUseMarkup());
290
3.64k
  SStream_concat(O, "%s", "]");
291
3.64k
  SStream_concat0(O, markup(">"));
292
3.64k
}
293
294
static inline void printAddrModeTBB(MCInst *MI, unsigned Op, SStream *O)
295
153
{
296
153
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrModeTBB, Op);
297
153
  MCOperand *MO1 = MCInst_getOperand(MI, (Op));
298
153
  MCOperand *MO2 = MCInst_getOperand(MI, (Op + 1));
299
153
  SStream_concat(O, "%s", markup("<mem:"));
300
153
  SStream_concat0(O, "[");
301
153
  printRegName(O, MCOperand_getReg(MO1));
302
153
  SStream_concat0(O, ", ");
303
153
  printRegName(O, MCOperand_getReg(MO2));
304
153
  SStream_concat(O, "%s", "]");
305
153
  SStream_concat0(O, markup(">"));
306
153
}
307
308
static inline void printAddrModeTBH(MCInst *MI, unsigned Op, SStream *O)
309
252
{
310
252
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrModeTBH, Op);
311
252
  MCOperand *MO1 = MCInst_getOperand(MI, (Op));
312
252
  MCOperand *MO2 = MCInst_getOperand(MI, (Op + 1));
313
252
  SStream_concat(O, "%s", markup("<mem:"));
314
252
  SStream_concat0(O, "[");
315
252
  printRegName(O, MCOperand_getReg(MO1));
316
252
  SStream_concat0(O, ", ");
317
252
  printRegName(O, MCOperand_getReg(MO2));
318
252
  SStream_concat(O, "%s%s%s%s%s", ", lsl ", markup("<imm:"), "#1",
319
252
           markup(">"), "]");
320
252
  SStream_concat0(O, markup(">"));
321
252
}
322
323
static inline void printAddrMode2Operand(MCInst *MI, unsigned Op, SStream *O)
324
3.64k
{
325
3.64k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrMode2Operand, Op);
326
3.64k
  MCOperand *MO1 = MCInst_getOperand(MI, (Op));
327
328
3.64k
  if (!MCOperand_isReg(
329
3.64k
        MO1)) { // FIXME: This is for CP entries, but isn't right.
330
0
    printOperand(MI, Op, O);
331
0
    return;
332
0
  }
333
334
3.64k
  printAM2PreOrOffsetIndexOp(MI, Op, O);
335
3.64k
}
336
337
static inline void printAddrMode2OffsetOperand(MCInst *MI, unsigned OpNum,
338
                 SStream *O)
339
6.26k
{
340
6.26k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrMode2OffsetOperand, OpNum);
341
6.26k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
342
6.26k
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
343
344
6.26k
  if (!MCOperand_getReg(MO1)) {
345
3.56k
    unsigned ImmOffs = ARM_AM_getAM2Offset(MCOperand_getImm(MO2));
346
3.56k
    SStream_concat(O, "%s", markup("<imm:"));
347
3.56k
    SStream_concat1(O, '#');
348
3.56k
    SStream_concat(O, "%s",
349
3.56k
             ARM_AM_getAddrOpcStr(
350
3.56k
               ARM_AM_getAM2Op(MCOperand_getImm(MO2))));
351
3.56k
    printUInt32(O, ImmOffs);
352
3.56k
    SStream_concat0(O, markup(">"));
353
3.56k
    return;
354
3.56k
  }
355
356
2.69k
  SStream_concat0(O, ARM_AM_getAddrOpcStr(
357
2.69k
           ARM_AM_getAM2Op(MCOperand_getImm(MO2))));
358
2.69k
  printRegName(O, MCOperand_getReg(MO1));
359
360
2.69k
  printRegImmShift(MI, O, ARM_AM_getAM2ShiftOpc(MCOperand_getImm(MO2)),
361
2.69k
       ARM_AM_getAM2Offset(MCOperand_getImm(MO2)),
362
2.69k
       getUseMarkup());
363
2.69k
}
364
365
//===--------------------------------------------------------------------===//
366
// Addressing Mode #3
367
//===--------------------------------------------------------------------===//
368
369
static inline void printAM3PreOrOffsetIndexOp(MCInst *MI, unsigned Op,
370
                SStream *O, bool AlwaysPrintImm0)
371
2.33k
{
372
2.33k
  MCOperand *MO1 = MCInst_getOperand(MI, (Op));
373
2.33k
  MCOperand *MO2 = MCInst_getOperand(MI, (Op + 1));
374
2.33k
  MCOperand *MO3 = MCInst_getOperand(MI, (Op + 2));
375
376
2.33k
  SStream_concat(O, "%s", markup("<mem:"));
377
2.33k
  SStream_concat0(O, "[");
378
379
2.33k
  printRegName(O, MCOperand_getReg(MO1));
380
381
2.33k
  if (MCOperand_getReg(MO2)) {
382
1.27k
    SStream_concat(O, "%s", ", ");
383
1.27k
    SStream_concat0(O, ARM_AM_getAddrOpcStr(ARM_AM_getAM3Op(
384
1.27k
             MCOperand_getImm(MO3))));
385
1.27k
    printRegName(O, MCOperand_getReg(MO2));
386
1.27k
    SStream_concat1(O, ']');
387
1.27k
    SStream_concat0(O, markup(">"));
388
1.27k
    return;
389
1.27k
  }
390
391
  // If the op is sub we have to print the immediate even if it is 0
392
1.06k
  unsigned ImmOffs = ARM_AM_getAM3Offset(MCOperand_getImm(MO3));
393
1.06k
  ARM_AM_AddrOpc op = ARM_AM_getAM3Op(MCOperand_getImm(MO3));
394
395
1.06k
  if (AlwaysPrintImm0 || ImmOffs || (op == ARM_AM_sub)) {
396
1.02k
    SStream_concat(O, "%s%s%s%s", ", ", markup("<imm:"), "#",
397
1.02k
             ARM_AM_getAddrOpcStr(op));
398
1.02k
    printUInt32(O, ImmOffs);
399
1.02k
    SStream_concat0(O, markup(">"));
400
1.02k
  }
401
1.06k
  SStream_concat1(O, ']');
402
1.06k
  SStream_concat0(O, markup(">"));
403
1.06k
}
404
405
#define DEFINE_printAddrMode3Operand(AlwaysPrintImm0) \
406
  static inline void CONCAT(printAddrMode3Operand, AlwaysPrintImm0)( \
407
    MCInst * MI, unsigned Op, SStream *O) \
408
2.33k
  { \
409
2.33k
    ARM_add_cs_detail_1(MI, \
410
2.33k
            CONCAT(ARM_OP_GROUP_AddrMode3Operand, \
411
2.33k
             AlwaysPrintImm0), \
412
2.33k
            Op, AlwaysPrintImm0); \
413
2.33k
    MCOperand *MO1 = MCInst_getOperand(MI, (Op)); \
414
2.33k
    if (!MCOperand_isReg(MO1)) { \
415
0
      printOperand(MI, Op, O); \
416
0
      return; \
417
0
    } \
418
2.33k
\
419
2.33k
    printAM3PreOrOffsetIndexOp(MI, Op, O, AlwaysPrintImm0); \
420
2.33k
  }
ARMInstPrinter.c:printAddrMode3Operand_0
Line
Count
Source
408
1.02k
  { \
409
1.02k
    ARM_add_cs_detail_1(MI, \
410
1.02k
            CONCAT(ARM_OP_GROUP_AddrMode3Operand, \
411
1.02k
             AlwaysPrintImm0), \
412
1.02k
            Op, AlwaysPrintImm0); \
413
1.02k
    MCOperand *MO1 = MCInst_getOperand(MI, (Op)); \
414
1.02k
    if (!MCOperand_isReg(MO1)) { \
415
0
      printOperand(MI, Op, O); \
416
0
      return; \
417
0
    } \
418
1.02k
\
419
1.02k
    printAM3PreOrOffsetIndexOp(MI, Op, O, AlwaysPrintImm0); \
420
1.02k
  }
ARMInstPrinter.c:printAddrMode3Operand_1
Line
Count
Source
408
1.31k
  { \
409
1.31k
    ARM_add_cs_detail_1(MI, \
410
1.31k
            CONCAT(ARM_OP_GROUP_AddrMode3Operand, \
411
1.31k
             AlwaysPrintImm0), \
412
1.31k
            Op, AlwaysPrintImm0); \
413
1.31k
    MCOperand *MO1 = MCInst_getOperand(MI, (Op)); \
414
1.31k
    if (!MCOperand_isReg(MO1)) { \
415
0
      printOperand(MI, Op, O); \
416
0
      return; \
417
0
    } \
418
1.31k
\
419
1.31k
    printAM3PreOrOffsetIndexOp(MI, Op, O, AlwaysPrintImm0); \
420
1.31k
  }
421
DEFINE_printAddrMode3Operand(false);
422
DEFINE_printAddrMode3Operand(true);
423
424
static inline void printAddrMode3OffsetOperand(MCInst *MI, unsigned OpNum,
425
                 SStream *O)
426
2.48k
{
427
2.48k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrMode3OffsetOperand, OpNum);
428
2.48k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
429
2.48k
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
430
431
2.48k
  if (MCOperand_getReg(MO1)) {
432
1.70k
    SStream_concat0(O, ARM_AM_getAddrOpcStr(ARM_AM_getAM3Op(
433
1.70k
             MCOperand_getImm(MO2))));
434
1.70k
    printRegName(O, MCOperand_getReg(MO1));
435
1.70k
    return;
436
1.70k
  }
437
438
780
  unsigned ImmOffs = ARM_AM_getAM3Offset(MCOperand_getImm(MO2));
439
780
  SStream_concat(O, "%s", markup("<imm:"));
440
780
  SStream_concat1(O, '#');
441
780
  SStream_concat(
442
780
    O, "%s",
443
780
    ARM_AM_getAddrOpcStr(ARM_AM_getAM3Op(MCOperand_getImm(MO2))));
444
780
  printUInt32(O, ImmOffs);
445
780
  SStream_concat0(O, markup(">"));
446
780
}
447
448
static inline void printPostIdxImm8Operand(MCInst *MI, unsigned OpNum,
449
             SStream *O)
450
389
{
451
389
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_PostIdxImm8Operand, OpNum);
452
389
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
453
389
  unsigned Imm = MCOperand_getImm(MO);
454
389
  SStream_concat(O, "%s", markup("<imm:"));
455
389
  SStream_concat1(O, '#');
456
389
  SStream_concat(O, "%s", ((Imm & 256) ? "" : "-"));
457
389
  printUInt32(O, (Imm & 0xff));
458
389
  SStream_concat0(O, markup(">"));
459
389
}
460
461
static inline void printPostIdxRegOperand(MCInst *MI, unsigned OpNum,
462
            SStream *O)
463
721
{
464
721
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_PostIdxRegOperand, OpNum);
465
721
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
466
721
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
467
468
721
  SStream_concat0(O, (MCOperand_getImm(MO2) ? "" : "-"));
469
721
  printRegName(O, MCOperand_getReg(MO1));
470
721
}
471
472
static inline void printPostIdxImm8s4Operand(MCInst *MI, unsigned OpNum,
473
               SStream *O)
474
5.55k
{
475
5.55k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_PostIdxImm8s4Operand, OpNum);
476
5.55k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
477
5.55k
  unsigned Imm = MCOperand_getImm(MO);
478
5.55k
  SStream_concat(O, "%s", markup("<imm:"));
479
5.55k
  SStream_concat1(O, '#');
480
5.55k
  SStream_concat(O, "%s", ((Imm & 256) ? "" : "-"));
481
5.55k
  printUInt32(O, (Imm & 0xff) << 2);
482
5.55k
  SStream_concat0(O, markup(">"));
483
5.55k
}
484
485
#define DEFINE_printMveAddrModeRQOperand(shift) \
486
  static inline void CONCAT(printMveAddrModeRQOperand, shift)( \
487
    MCInst * MI, unsigned OpNum, SStream *O) \
488
254
  { \
489
254
    ARM_add_cs_detail_1( \
490
254
      MI, CONCAT(ARM_OP_GROUP_MveAddrModeRQOperand, shift), \
491
254
      OpNum, shift); \
492
254
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
493
254
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
494
254
\
495
254
    SStream_concat(O, "%s", markup("<mem:")); \
496
254
    SStream_concat0(O, "["); \
497
254
    printRegName(O, MCOperand_getReg(MO1)); \
498
254
    SStream_concat0(O, ", "); \
499
254
    printRegName(O, MCOperand_getReg(MO2)); \
500
254
\
501
254
    if (shift > 0) \
502
254
      printRegImmShift(MI, O, ARM_AM_uxtw, shift, \
503
147
           getUseMarkup()); \
504
254
\
505
254
    SStream_concat(O, "%s", "]"); \
506
254
    SStream_concat0(O, markup(">")); \
507
254
  }
ARMInstPrinter.c:printMveAddrModeRQOperand_0
Line
Count
Source
488
107
  { \
489
107
    ARM_add_cs_detail_1( \
490
107
      MI, CONCAT(ARM_OP_GROUP_MveAddrModeRQOperand, shift), \
491
107
      OpNum, shift); \
492
107
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
493
107
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
494
107
\
495
107
    SStream_concat(O, "%s", markup("<mem:")); \
496
107
    SStream_concat0(O, "["); \
497
107
    printRegName(O, MCOperand_getReg(MO1)); \
498
107
    SStream_concat0(O, ", "); \
499
107
    printRegName(O, MCOperand_getReg(MO2)); \
500
107
\
501
107
    if (shift > 0) \
502
107
      printRegImmShift(MI, O, ARM_AM_uxtw, shift, \
503
0
           getUseMarkup()); \
504
107
\
505
107
    SStream_concat(O, "%s", "]"); \
506
107
    SStream_concat0(O, markup(">")); \
507
107
  }
ARMInstPrinter.c:printMveAddrModeRQOperand_3
Line
Count
Source
488
29
  { \
489
29
    ARM_add_cs_detail_1( \
490
29
      MI, CONCAT(ARM_OP_GROUP_MveAddrModeRQOperand, shift), \
491
29
      OpNum, shift); \
492
29
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
493
29
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
494
29
\
495
29
    SStream_concat(O, "%s", markup("<mem:")); \
496
29
    SStream_concat0(O, "["); \
497
29
    printRegName(O, MCOperand_getReg(MO1)); \
498
29
    SStream_concat0(O, ", "); \
499
29
    printRegName(O, MCOperand_getReg(MO2)); \
500
29
\
501
29
    if (shift > 0) \
502
29
      printRegImmShift(MI, O, ARM_AM_uxtw, shift, \
503
29
           getUseMarkup()); \
504
29
\
505
29
    SStream_concat(O, "%s", "]"); \
506
29
    SStream_concat0(O, markup(">")); \
507
29
  }
ARMInstPrinter.c:printMveAddrModeRQOperand_1
Line
Count
Source
488
35
  { \
489
35
    ARM_add_cs_detail_1( \
490
35
      MI, CONCAT(ARM_OP_GROUP_MveAddrModeRQOperand, shift), \
491
35
      OpNum, shift); \
492
35
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
493
35
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
494
35
\
495
35
    SStream_concat(O, "%s", markup("<mem:")); \
496
35
    SStream_concat0(O, "["); \
497
35
    printRegName(O, MCOperand_getReg(MO1)); \
498
35
    SStream_concat0(O, ", "); \
499
35
    printRegName(O, MCOperand_getReg(MO2)); \
500
35
\
501
35
    if (shift > 0) \
502
35
      printRegImmShift(MI, O, ARM_AM_uxtw, shift, \
503
35
           getUseMarkup()); \
504
35
\
505
35
    SStream_concat(O, "%s", "]"); \
506
35
    SStream_concat0(O, markup(">")); \
507
35
  }
ARMInstPrinter.c:printMveAddrModeRQOperand_2
Line
Count
Source
488
83
  { \
489
83
    ARM_add_cs_detail_1( \
490
83
      MI, CONCAT(ARM_OP_GROUP_MveAddrModeRQOperand, shift), \
491
83
      OpNum, shift); \
492
83
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
493
83
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
494
83
\
495
83
    SStream_concat(O, "%s", markup("<mem:")); \
496
83
    SStream_concat0(O, "["); \
497
83
    printRegName(O, MCOperand_getReg(MO1)); \
498
83
    SStream_concat0(O, ", "); \
499
83
    printRegName(O, MCOperand_getReg(MO2)); \
500
83
\
501
83
    if (shift > 0) \
502
83
      printRegImmShift(MI, O, ARM_AM_uxtw, shift, \
503
83
           getUseMarkup()); \
504
83
\
505
83
    SStream_concat(O, "%s", "]"); \
506
83
    SStream_concat0(O, markup(">")); \
507
83
  }
508
DEFINE_printMveAddrModeRQOperand(0);
509
DEFINE_printMveAddrModeRQOperand(3);
510
DEFINE_printMveAddrModeRQOperand(1);
511
DEFINE_printMveAddrModeRQOperand(2);
512
513
#define DEFINE_printAddrMode5Operand(AlwaysPrintImm0) \
514
  static inline void CONCAT(printAddrMode5Operand, AlwaysPrintImm0)( \
515
    MCInst * MI, unsigned OpNum, SStream *O) \
516
13.4k
  { \
517
13.4k
    ARM_add_cs_detail_1(MI, \
518
13.4k
            CONCAT(ARM_OP_GROUP_AddrMode5Operand, \
519
13.4k
             AlwaysPrintImm0), \
520
13.4k
            OpNum, AlwaysPrintImm0); \
521
13.4k
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
522
13.4k
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
523
13.4k
\
524
13.4k
    SStream_concat(O, "%s", markup("<mem:")); \
525
13.4k
    SStream_concat0(O, "["); \
526
13.4k
    printRegName(O, MCOperand_getReg(MO1)); \
527
13.4k
\
528
13.4k
    unsigned ImmOffs = ARM_AM_getAM5Offset(MCOperand_getImm(MO2)); \
529
13.4k
    ARM_AM_AddrOpc Op = ARM_AM_getAM5Op(MCOperand_getImm(MO2)); \
530
13.4k
    if (AlwaysPrintImm0 || ImmOffs || Op == ARM_AM_sub) { \
531
13.0k
      SStream_concat(O, "%s%s%s%s", ", ", markup("<imm:"), \
532
13.0k
               "#", ARM_AM_getAddrOpcStr(Op)); \
533
13.0k
      printUInt32(O, ImmOffs * 4); \
534
13.0k
      SStream_concat0(O, markup(">")); \
535
13.0k
    } \
536
13.4k
    SStream_concat(O, "%s", "]"); \
537
13.4k
    SStream_concat0(O, markup(">")); \
538
13.4k
  }
ARMInstPrinter.c:printAddrMode5Operand_0
Line
Count
Source
516
5.43k
  { \
517
5.43k
    ARM_add_cs_detail_1(MI, \
518
5.43k
            CONCAT(ARM_OP_GROUP_AddrMode5Operand, \
519
5.43k
             AlwaysPrintImm0), \
520
5.43k
            OpNum, AlwaysPrintImm0); \
521
5.43k
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
522
5.43k
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
523
5.43k
\
524
5.43k
    SStream_concat(O, "%s", markup("<mem:")); \
525
5.43k
    SStream_concat0(O, "["); \
526
5.43k
    printRegName(O, MCOperand_getReg(MO1)); \
527
5.43k
\
528
5.43k
    unsigned ImmOffs = ARM_AM_getAM5Offset(MCOperand_getImm(MO2)); \
529
5.43k
    ARM_AM_AddrOpc Op = ARM_AM_getAM5Op(MCOperand_getImm(MO2)); \
530
5.43k
    if (AlwaysPrintImm0 || ImmOffs || Op == ARM_AM_sub) { \
531
5.12k
      SStream_concat(O, "%s%s%s%s", ", ", markup("<imm:"), \
532
5.12k
               "#", ARM_AM_getAddrOpcStr(Op)); \
533
5.12k
      printUInt32(O, ImmOffs * 4); \
534
5.12k
      SStream_concat0(O, markup(">")); \
535
5.12k
    } \
536
5.43k
    SStream_concat(O, "%s", "]"); \
537
5.43k
    SStream_concat0(O, markup(">")); \
538
5.43k
  }
ARMInstPrinter.c:printAddrMode5Operand_1
Line
Count
Source
516
7.96k
  { \
517
7.96k
    ARM_add_cs_detail_1(MI, \
518
7.96k
            CONCAT(ARM_OP_GROUP_AddrMode5Operand, \
519
7.96k
             AlwaysPrintImm0), \
520
7.96k
            OpNum, AlwaysPrintImm0); \
521
7.96k
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
522
7.96k
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
523
7.96k
\
524
7.96k
    SStream_concat(O, "%s", markup("<mem:")); \
525
7.96k
    SStream_concat0(O, "["); \
526
7.96k
    printRegName(O, MCOperand_getReg(MO1)); \
527
7.96k
\
528
7.96k
    unsigned ImmOffs = ARM_AM_getAM5Offset(MCOperand_getImm(MO2)); \
529
7.96k
    ARM_AM_AddrOpc Op = ARM_AM_getAM5Op(MCOperand_getImm(MO2)); \
530
7.96k
    if (AlwaysPrintImm0 || ImmOffs || Op == ARM_AM_sub) { \
531
7.96k
      SStream_concat(O, "%s%s%s%s", ", ", markup("<imm:"), \
532
7.96k
               "#", ARM_AM_getAddrOpcStr(Op)); \
533
7.96k
      printUInt32(O, ImmOffs * 4); \
534
7.96k
      SStream_concat0(O, markup(">")); \
535
7.96k
    } \
536
7.96k
    SStream_concat(O, "%s", "]"); \
537
7.96k
    SStream_concat0(O, markup(">")); \
538
7.96k
  }
539
DEFINE_printAddrMode5Operand(false);
540
DEFINE_printAddrMode5Operand(true);
541
542
#define DEFINE_printAddrMode5FP16Operand(AlwaysPrintImm0) \
543
  static inline void CONCAT(printAddrMode5FP16Operand, AlwaysPrintImm0)( \
544
    MCInst * MI, unsigned OpNum, SStream *O) \
545
296
  { \
546
296
    ARM_add_cs_detail_1(MI, \
547
296
            CONCAT(ARM_OP_GROUP_AddrMode5FP16Operand, \
548
296
             AlwaysPrintImm0), \
549
296
            OpNum, AlwaysPrintImm0); \
550
296
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
551
296
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
552
296
\
553
296
    if (!MCOperand_isReg(MO1)) { \
554
0
      printOperand(MI, OpNum, O); \
555
0
      return; \
556
0
    } \
557
296
\
558
296
    SStream_concat(O, "%s", markup("<mem:")); \
559
296
    SStream_concat0(O, "["); \
560
296
    printRegName(O, MCOperand_getReg(MO1)); \
561
296
\
562
296
    unsigned ImmOffs = \
563
296
      ARM_AM_getAM5FP16Offset(MCOperand_getImm(MO2)); \
564
296
    unsigned Op = ARM_AM_getAM5FP16Op(MCOperand_getImm(MO2)); \
565
296
    if (AlwaysPrintImm0 || ImmOffs || Op == ARM_AM_sub) { \
566
236
      SStream_concat( \
567
236
        O, "%s%s%s%s", ", ", markup("<imm:"), "#", \
568
236
        ARM_AM_getAddrOpcStr(ARM_AM_getAM5FP16Op( \
569
236
          MCOperand_getImm(MO2)))); \
570
236
      printUInt32(O, ImmOffs * 2); \
571
236
      SStream_concat0(O, markup(">")); \
572
236
    } \
573
296
    SStream_concat(O, "%s", "]"); \
574
296
    SStream_concat0(O, markup(">")); \
575
296
  }
576
DEFINE_printAddrMode5FP16Operand(false);
577
578
static inline void printAddrMode6Operand(MCInst *MI, unsigned OpNum, SStream *O)
579
29.1k
{
580
29.1k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrMode6Operand, OpNum);
581
29.1k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
582
29.1k
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
583
584
29.1k
  SStream_concat(O, "%s", markup("<mem:"));
585
29.1k
  SStream_concat0(O, "[");
586
29.1k
  printRegName(O, MCOperand_getReg(MO1));
587
29.1k
  if (MCOperand_getImm(MO2)) {
588
13.2k
    SStream_concat(O, "%s", ":");
589
13.2k
    printInt64(O, ((uint32_t)MCOperand_getImm(MO2)) << 3);
590
13.2k
  }
591
29.1k
  SStream_concat(O, "%s", "]");
592
29.1k
  SStream_concat0(O, markup(">"));
593
29.1k
}
594
595
static inline void printAddrMode7Operand(MCInst *MI, unsigned OpNum, SStream *O)
596
23.8k
{
597
23.8k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrMode7Operand, OpNum);
598
23.8k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
599
23.8k
  SStream_concat(O, "%s", markup("<mem:"));
600
23.8k
  SStream_concat0(O, "[");
601
23.8k
  printRegName(O, MCOperand_getReg(MO1));
602
23.8k
  SStream_concat(O, "%s", "]");
603
23.8k
  SStream_concat0(O, markup(">"));
604
23.8k
}
605
606
static inline void printAddrMode6OffsetOperand(MCInst *MI, unsigned OpNum,
607
                 SStream *O)
608
8.86k
{
609
8.86k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_AddrMode6OffsetOperand, OpNum);
610
8.86k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
611
8.86k
  if (MCOperand_getReg(MO) == 0)
612
3.21k
    SStream_concat0(O, "!");
613
5.65k
  else {
614
5.65k
    SStream_concat0(O, ", ");
615
5.65k
    printRegName(O, MCOperand_getReg(MO));
616
5.65k
  }
617
8.86k
}
618
619
static inline void printBitfieldInvMaskImmOperand(MCInst *MI, unsigned OpNum,
620
              SStream *O)
621
803
{
622
803
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_BitfieldInvMaskImmOperand, OpNum);
623
803
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
624
803
  uint32_t v = ~MCOperand_getImm(MO);
625
803
  int32_t lsb = CountTrailingZeros_32(v);
626
803
  int32_t width = (32 - countLeadingZeros(v)) - lsb;
627
628
803
  SStream_concat(O, "%s", markup("<imm:"));
629
803
  SStream_concat1(O, '#');
630
803
  printInt32(O, lsb);
631
803
  SStream_concat(O, "%s%s%s", markup(">"), ", ", markup("<imm:"));
632
803
  printInt32Bang(O, width);
633
803
  SStream_concat0(O, markup(">"));
634
803
}
635
636
static inline void printMemBOption(MCInst *MI, unsigned OpNum, SStream *O)
637
1.36k
{
638
1.36k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_MemBOption, OpNum);
639
1.36k
  unsigned val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
640
1.36k
  SStream_concat0(O, ARM_MB_MemBOptToString(
641
1.36k
           val, ARM_getFeatureBits(MI->csh->mode,
642
1.36k
                 ARM_HasV8Ops)));
643
1.36k
}
644
645
static inline void printInstSyncBOption(MCInst *MI, unsigned OpNum, SStream *O)
646
442
{
647
442
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_InstSyncBOption, OpNum);
648
442
  unsigned val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
649
442
  SStream_concat0(O, ARM_ISB_InstSyncBOptToString(val));
650
442
}
651
652
static inline void printTraceSyncBOption(MCInst *MI, unsigned OpNum, SStream *O)
653
0
{
654
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_TraceSyncBOption, OpNum);
655
0
  unsigned val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
656
0
  SStream_concat0(O, ARM_TSB_TraceSyncBOptToString(val));
657
0
}
658
659
static inline void printShiftImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
660
793
{
661
793
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ShiftImmOperand, OpNum);
662
793
  unsigned ShiftOp = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
663
793
  bool isASR = (ShiftOp & (1 << 5)) != 0;
664
793
  unsigned Amt = ShiftOp & 0x1f;
665
793
  if (isASR) {
666
366
    SStream_concat(O, "%s%s%s", ", asr ", markup("<imm:"), "#");
667
366
    printUInt32(O, Amt == 0 ? 32 : Amt);
668
366
    SStream_concat0(O, markup(">"));
669
427
  } else if (Amt) {
670
266
    SStream_concat(O, "%s%s%s", ", lsl ", markup("<imm:"), "#");
671
266
    printUInt32(O, Amt);
672
266
    SStream_concat0(O, markup(">"));
673
266
  }
674
793
}
675
676
static inline void printPKHLSLShiftImm(MCInst *MI, unsigned OpNum, SStream *O)
677
314
{
678
314
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_PKHLSLShiftImm, OpNum);
679
314
  unsigned Imm = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
680
314
  if (Imm == 0)
681
173
    return;
682
683
141
  SStream_concat(O, "%s%s%s", ", lsl ", markup("<imm:"), "#");
684
141
  printUInt32(O, Imm);
685
141
  SStream_concat0(O, markup(">"));
686
141
}
687
688
static inline void printPKHASRShiftImm(MCInst *MI, unsigned OpNum, SStream *O)
689
153
{
690
153
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_PKHASRShiftImm, OpNum);
691
153
  unsigned Imm = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
692
  // A shift amount of 32 is encoded as 0.
693
153
  if (Imm == 0)
694
52
    Imm = 32;
695
696
153
  SStream_concat(O, "%s%s%s", ", asr ", markup("<imm:"), "#");
697
153
  printUInt32(O, Imm);
698
153
  SStream_concat0(O, markup(">"));
699
153
}
700
701
static inline void printGPRPairOperand(MCInst *MI, unsigned OpNum, SStream *O)
702
556
{
703
556
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_GPRPairOperand, OpNum);
704
556
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
705
556
  printRegName(O, MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_gsub_0));
706
556
  SStream_concat0(O, ", ");
707
556
  printRegName(O, MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_gsub_1));
708
556
}
709
710
static inline void printSetendOperand(MCInst *MI, unsigned OpNum, SStream *O)
711
248
{
712
248
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_SetendOperand, OpNum);
713
248
  MCOperand *Op = MCInst_getOperand(MI, (OpNum));
714
248
  if (MCOperand_getImm(Op))
715
190
    SStream_concat0(O, "be");
716
58
  else
717
58
    SStream_concat0(O, "le");
718
248
}
719
720
static inline void printCPSIMod(MCInst *MI, unsigned OpNum, SStream *O)
721
1.04k
{
722
1.04k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_CPSIMod, OpNum);
723
1.04k
  MCOperand *Op = MCInst_getOperand(MI, (OpNum));
724
1.04k
  SStream_concat0(O, ARM_PROC_IModToString(MCOperand_getImm(Op)));
725
1.04k
}
726
727
static inline void printCPSIFlag(MCInst *MI, unsigned OpNum, SStream *O)
728
1.04k
{
729
1.04k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_CPSIFlag, OpNum);
730
1.04k
  MCOperand *Op = MCInst_getOperand(MI, (OpNum));
731
1.04k
  unsigned IFlags = MCOperand_getImm(Op);
732
4.19k
  for (int i = 2; i >= 0; --i)
733
3.14k
    if (IFlags & (1 << i))
734
995
      SStream_concat0(O, ARM_PROC_IFlagsToString(1 << i));
735
736
1.04k
  if (IFlags == 0)
737
158
    SStream_concat0(O, "none");
738
1.04k
}
739
740
static inline void printMSRMaskOperand(MCInst *MI, unsigned OpNum, SStream *O)
741
6.37k
{
742
6.37k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_MSRMaskOperand, OpNum);
743
6.37k
  MCOperand *Op = MCInst_getOperand(MI, (OpNum));
744
745
6.37k
  if (ARM_getFeatureBits(MI->csh->mode, ARM_FeatureMClass)) {
746
5.57k
    unsigned SYSm = MCOperand_getImm(Op) & 0xFFF; // 12-bit SYSm
747
5.57k
    unsigned Opcode = MCInst_getOpcode(MI);
748
749
    // For writes, handle extended mask bits if the DSP extension is
750
    // present.
751
5.57k
    if (Opcode == ARM_t2MSR_M &&
752
4.56k
        ARM_getFeatureBits(MI->csh->mode, ARM_FeatureDSP)) {
753
4.56k
      const ARMSysReg_MClassSysReg *TheReg =
754
4.56k
        ARMSysReg_lookupMClassSysRegBy12bitSYSmValue(
755
4.56k
          SYSm);
756
4.56k
      if (TheReg && MClassSysReg_isInRequiredFeatures(
757
1.93k
                TheReg, ARM_FeatureDSP)) {
758
600
        SStream_concat0(O, TheReg->Name);
759
600
        return;
760
600
      }
761
4.56k
    }
762
763
    // Handle the basic 8-bit mask.
764
4.97k
    SYSm &= 0xff;
765
4.97k
    if (Opcode == ARM_t2MSR_M &&
766
3.96k
        ARM_getFeatureBits(MI->csh->mode, ARM_HasV7Ops)) {
767
      // ARMv7-M deprecates using MSR APSR without a _<bits> qualifier as
768
      // an alias for MSR APSR_nzcvq.
769
3.96k
      const ARMSysReg_MClassSysReg *TheReg =
770
3.96k
        ARMSysReg_lookupMClassSysRegAPSRNonDeprecated(
771
3.96k
          SYSm);
772
3.96k
      if (TheReg) {
773
434
        SStream_concat0(O, TheReg->Name);
774
434
        return;
775
434
      }
776
3.96k
    }
777
778
4.53k
    const ARMSysReg_MClassSysReg *TheReg =
779
4.53k
      ARMSysReg_lookupMClassSysRegBy8bitSYSmValue(SYSm);
780
4.53k
    if (TheReg) {
781
3.34k
      SStream_concat0(O, TheReg->Name);
782
3.34k
      return;
783
3.34k
    }
784
785
1.19k
    printUInt32(O, SYSm);
786
787
1.19k
    return;
788
4.53k
  }
789
790
  // As special cases, CPSR_f, CPSR_s and CPSR_fs prefer printing as
791
  // APSR_nzcvq, APSR_g and APSRnzcvqg, respectively.
792
801
  unsigned SpecRegRBit = MCOperand_getImm(Op) >> 4;
793
801
  unsigned Mask = MCOperand_getImm(Op) & 0xf;
794
795
801
  if (!SpecRegRBit && (Mask == 8 || Mask == 4 || Mask == 12)) {
796
509
    SStream_concat0(O, "apsr_");
797
509
    switch (Mask) {
798
0
    default:
799
0
      CS_ASSERT_RET(0 && "Unexpected mask value!");
800
62
    case 4:
801
62
      SStream_concat0(O, "g");
802
62
      return;
803
28
    case 8:
804
28
      SStream_concat0(O, "nzcvq");
805
28
      return;
806
419
    case 12:
807
419
      SStream_concat0(O, "nzcvqg");
808
419
      return;
809
509
    }
810
509
  }
811
812
292
  if (SpecRegRBit)
813
136
    SStream_concat0(O, "spsr");
814
156
  else
815
156
    SStream_concat0(O, "cpsr");
816
817
292
  if (Mask) {
818
243
    SStream_concat0(O, "_");
819
820
243
    if (Mask & 8)
821
151
      SStream_concat0(O, "f");
822
823
243
    if (Mask & 4)
824
171
      SStream_concat0(O, "s");
825
826
243
    if (Mask & 2)
827
66
      SStream_concat0(O, "x");
828
829
243
    if (Mask & 1)
830
195
      SStream_concat0(O, "c");
831
243
  }
832
292
}
833
834
static inline void printBankedRegOperand(MCInst *MI, unsigned OpNum, SStream *O)
835
622
{
836
622
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_BankedRegOperand, OpNum);
837
622
  uint32_t Banked = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
838
622
  const ARMBankedReg_BankedReg *TheReg =
839
622
    ARMBankedReg_lookupBankedRegByEncoding(Banked);
840
841
622
  const char *Name = TheReg->Name;
842
843
  // uint32_t isSPSR = (Banked & 0x20) >> 5;
844
  // if (isSPSR)
845
  //  Name.replace(0, 4, "SPSR"); // convert 'spsr_' to 'SPSR_'
846
622
  SStream_concat0(O, Name);
847
622
}
848
849
static inline void printMandatoryPredicateOperand(MCInst *MI, unsigned OpNum,
850
              SStream *O)
851
13.7k
{
852
13.7k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_MandatoryPredicateOperand, OpNum);
853
13.7k
  ARMCC_CondCodes CC = (ARMCC_CondCodes)MCOperand_getImm(
854
13.7k
    MCInst_getOperand(MI, (OpNum)));
855
13.7k
  SStream_concat0(O, ARMCondCodeToString(CC));
856
13.7k
}
857
858
static inline void
859
printMandatoryRestrictedPredicateOperand(MCInst *MI, unsigned OpNum, SStream *O)
860
6.35k
{
861
6.35k
  ARM_add_cs_detail_0(
862
6.35k
    MI, ARM_OP_GROUP_MandatoryRestrictedPredicateOperand, OpNum);
863
6.35k
  if ((ARMCC_CondCodes)MCOperand_getImm(MCInst_getOperand(MI, (OpNum))) ==
864
6.35k
      ARMCC_HS)
865
617
    SStream_concat0(O, "cs");
866
5.73k
  else
867
5.73k
    printMandatoryPredicateOperand(MI, OpNum, O);
868
6.35k
}
869
870
static inline void
871
printMandatoryInvertedPredicateOperand(MCInst *MI, unsigned OpNum, SStream *O)
872
159
{
873
159
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_MandatoryInvertedPredicateOperand,
874
159
          OpNum);
875
159
  ARMCC_CondCodes CC = (ARMCC_CondCodes)MCOperand_getImm(
876
159
    MCInst_getOperand(MI, (OpNum)));
877
159
  SStream_concat0(O, ARMCondCodeToString(ARMCC_getOppositeCondition(CC)));
878
159
}
879
880
static inline void printNoHashImmediate(MCInst *MI, unsigned OpNum, SStream *O)
881
20.0k
{
882
20.0k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_NoHashImmediate, OpNum);
883
20.0k
  printInt64(O, MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
884
20.0k
}
885
886
static inline void printPImmediate(MCInst *MI, unsigned OpNum, SStream *O)
887
42.5k
{
888
42.5k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_PImmediate, OpNum);
889
42.5k
  SStream_concat(
890
42.5k
    O, "%s%" PRIu32, "p",
891
42.5k
    (uint32_t)MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
892
42.5k
}
893
894
static inline void printCImmediate(MCInst *MI, unsigned OpNum, SStream *O)
895
75.8k
{
896
75.8k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_CImmediate, OpNum);
897
75.8k
  SStream_concat(
898
75.8k
    O, "%s%" PRIu32, "c",
899
75.8k
    (uint32_t)MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
900
75.8k
}
901
902
static inline void printCoprocOptionImm(MCInst *MI, unsigned OpNum, SStream *O)
903
1.84k
{
904
1.84k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_CoprocOptionImm, OpNum);
905
1.84k
  SStream_concat(O, "%s", "{");
906
1.84k
  printInt64(O, MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
907
1.84k
  SStream_concat0(O, "}");
908
1.84k
}
909
910
#define DEFINE_printAdrLabelOperand(scale) \
911
  static inline void CONCAT(printAdrLabelOperand, scale)( \
912
    MCInst * MI, unsigned OpNum, SStream *O) \
913
11.0k
  { \
914
11.0k
    ARM_add_cs_detail_1( \
915
11.0k
      MI, CONCAT(ARM_OP_GROUP_AdrLabelOperand, scale), \
916
11.0k
      OpNum, scale); \
917
11.0k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
918
11.0k
\
919
11.0k
    if (MCOperand_isExpr(MO)) { \
920
0
      return; \
921
0
    } \
922
11.0k
\
923
11.0k
    int32_t OffImm = (uint32_t)MCOperand_getImm(MO) << scale; \
924
11.0k
\
925
11.0k
    SStream_concat0(O, markup("<imm:")); \
926
11.0k
    if (OffImm == INT32_MIN) \
927
11.0k
      SStream_concat0(O, "#-0"); \
928
11.0k
    else if (OffImm < 0) { \
929
374
      printInt32Bang(O, OffImm); \
930
10.6k
    } else { \
931
10.6k
      printInt32Bang(O, OffImm); \
932
10.6k
    } \
933
11.0k
    SStream_concat0(O, markup(">")); \
934
11.0k
  }
935
708
DEFINE_printAdrLabelOperand(0);
936
10.3k
DEFINE_printAdrLabelOperand(2);
937
938
#define DEFINE_printAdrLabelOperandAddr(scale) \
939
  static inline void CONCAT(printAdrLabelOperandAddr, scale)( \
940
    MCInst * MI, uint64_t Address, unsigned OpNum, SStream *O) \
941
10.3k
  { \
942
10.3k
    CONCAT(printAdrLabelOperand, scale)(MI, OpNum, O); \
943
10.3k
  }
944
DEFINE_printAdrLabelOperandAddr(2);
945
946
static inline void printThumbS4ImmOperand(MCInst *MI, unsigned OpNum,
947
            SStream *O)
948
9.08k
{
949
9.08k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbS4ImmOperand, OpNum);
950
9.08k
  SStream_concat(O, "%s", markup("<imm:"));
951
9.08k
  printInt64Bang(O, MCOperand_getImm(MCInst_getOperand(MI, (OpNum))) * 4);
952
9.08k
  SStream_concat0(O, markup(">"));
953
9.08k
}
954
955
static inline void printThumbSRImm(MCInst *MI, unsigned OpNum, SStream *O)
956
28.6k
{
957
28.6k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbSRImm, OpNum);
958
28.6k
  unsigned Imm = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
959
28.6k
  SStream_concat(O, "%s", markup("<imm:"));
960
28.6k
  printUInt32Bang(O, (Imm == 0 ? 32 : Imm));
961
28.6k
  SStream_concat0(O, markup(">"));
962
28.6k
}
963
964
static inline void printThumbITMask(MCInst *MI, unsigned OpNum, SStream *O)
965
7.53k
{
966
7.53k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbITMask, OpNum);
967
  // (3 - the number of trailing zeros) is the number of then / else.
968
7.53k
  unsigned Mask = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
969
7.53k
  unsigned NumTZ = CountTrailingZeros_32(Mask);
970
971
27.9k
  for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
972
20.3k
    if ((Mask >> Pos) & 1)
973
6.58k
      SStream_concat0(O, "e");
974
975
13.8k
    else
976
13.8k
      SStream_concat0(O, "t");
977
20.3k
  }
978
7.53k
}
979
980
static inline void printThumbAddrModeRROperand(MCInst *MI, unsigned Op,
981
                 SStream *O)
982
14.2k
{
983
14.2k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbAddrModeRROperand, Op);
984
14.2k
  MCOperand *MO1 = MCInst_getOperand(MI, (Op));
985
14.2k
  MCOperand *MO2 = MCInst_getOperand(MI, (Op + 1));
986
987
14.2k
  if (!MCOperand_isReg(
988
14.2k
        MO1)) { // FIXME: This is for CP entries, but isn't right.
989
0
    printOperand(MI, Op, O);
990
0
    return;
991
0
  }
992
993
14.2k
  SStream_concat(O, "%s", markup("<mem:"));
994
14.2k
  SStream_concat0(O, "[");
995
14.2k
  printRegName(O, MCOperand_getReg(MO1));
996
14.2k
  unsigned RegNum = MCOperand_getReg(MO2);
997
14.2k
  if (RegNum) {
998
14.2k
    SStream_concat0(O, ", ");
999
14.2k
    printRegName(O, RegNum);
1000
14.2k
  }
1001
14.2k
  SStream_concat(O, "%s", "]");
1002
14.2k
  SStream_concat0(O, markup(">"));
1003
14.2k
}
1004
1005
static inline void printThumbAddrModeImm5SOperand(MCInst *MI, unsigned Op,
1006
              SStream *O, unsigned Scale)
1007
90.4k
{
1008
90.4k
  MCOperand *MO1 = MCInst_getOperand(MI, (Op));
1009
90.4k
  MCOperand *MO2 = MCInst_getOperand(MI, (Op + 1));
1010
1011
90.4k
  if (!MCOperand_isReg(
1012
90.4k
        MO1)) { // FIXME: This is for CP entries, but isn't right.
1013
0
    printOperand(MI, Op, O);
1014
0
    return;
1015
0
  }
1016
1017
90.4k
  SStream_concat(O, "%s", markup("<mem:"));
1018
90.4k
  SStream_concat0(O, "[");
1019
90.4k
  printRegName(O, MCOperand_getReg(MO1));
1020
90.4k
  unsigned ImmOffs = MCOperand_getImm(MO2);
1021
90.4k
  if (ImmOffs) {
1022
84.9k
    SStream_concat(O, "%s%s", ", ", markup("<imm:"));
1023
84.9k
    printUInt32Bang(O, ImmOffs * Scale);
1024
84.9k
    SStream_concat0(O, markup(">"));
1025
84.9k
  }
1026
90.4k
  SStream_concat(O, "%s", "]");
1027
90.4k
  SStream_concat0(O, markup(">"));
1028
90.4k
}
1029
1030
static inline void printThumbAddrModeImm5S1Operand(MCInst *MI, unsigned Op,
1031
               SStream *O)
1032
23.2k
{
1033
23.2k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbAddrModeImm5S1Operand, Op);
1034
23.2k
  printThumbAddrModeImm5SOperand(MI, Op, O, 1);
1035
23.2k
}
1036
1037
static inline void printThumbAddrModeImm5S2Operand(MCInst *MI, unsigned Op,
1038
               SStream *O)
1039
24.3k
{
1040
24.3k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbAddrModeImm5S2Operand, Op);
1041
24.3k
  printThumbAddrModeImm5SOperand(MI, Op, O, 2);
1042
24.3k
}
1043
1044
static inline void printThumbAddrModeImm5S4Operand(MCInst *MI, unsigned Op,
1045
               SStream *O)
1046
28.4k
{
1047
28.4k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbAddrModeImm5S4Operand, Op);
1048
28.4k
  printThumbAddrModeImm5SOperand(MI, Op, O, 4);
1049
28.4k
}
1050
1051
static inline void printThumbAddrModeSPOperand(MCInst *MI, unsigned Op,
1052
                 SStream *O)
1053
14.3k
{
1054
14.3k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ThumbAddrModeSPOperand, Op);
1055
14.3k
  printThumbAddrModeImm5SOperand(MI, Op, O, 4);
1056
14.3k
}
1057
1058
// Constant shifts t2_so_reg is a 2-operand unit corresponding to the Thumb2
1059
// register with shift forms.
1060
// REG 0   0           - e.g. R5
1061
// REG IMM, SH_OPC     - e.g. R5, LSL #3
1062
static inline void printT2SOOperand(MCInst *MI, unsigned OpNum, SStream *O)
1063
1.95k
{
1064
1.95k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_T2SOOperand, OpNum);
1065
1.95k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
1066
1.95k
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
1067
1068
1.95k
  unsigned Reg = MCOperand_getReg(MO1);
1069
1.95k
  printRegName(O, Reg);
1070
1071
  // Print the shift opc.
1072
1073
1.95k
  printRegImmShift(MI, O, ARM_AM_getSORegShOp(MCOperand_getImm(MO2)),
1074
1.95k
       ARM_AM_getSORegOffset(MCOperand_getImm(MO2)),
1075
1.95k
       getUseMarkup());
1076
1.95k
}
1077
1078
#define DEFINE_printAddrModeImm12Operand(AlwaysPrintImm0) \
1079
  static inline void CONCAT(printAddrModeImm12Operand, AlwaysPrintImm0)( \
1080
    MCInst * MI, unsigned OpNum, SStream *O) \
1081
5.43k
  { \
1082
5.43k
    ARM_add_cs_detail_1(MI, \
1083
5.43k
            CONCAT(ARM_OP_GROUP_AddrModeImm12Operand, \
1084
5.43k
             AlwaysPrintImm0), \
1085
5.43k
            OpNum, AlwaysPrintImm0); \
1086
5.43k
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
1087
5.43k
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
1088
5.43k
\
1089
5.43k
    if (!MCOperand_isReg(MO1)) { \
1090
0
      printOperand(MI, OpNum, O); \
1091
0
      return; \
1092
0
    } \
1093
5.43k
\
1094
5.43k
    SStream_concat(O, "%s", markup("<mem:")); \
1095
5.43k
    SStream_concat0(O, "["); \
1096
5.43k
    printRegName(O, MCOperand_getReg(MO1)); \
1097
5.43k
\
1098
5.43k
    int32_t OffImm = (int32_t)MCOperand_getImm(MO2); \
1099
5.43k
    bool isSub = OffImm < 0; \
1100
5.43k
\
1101
5.43k
    if (OffImm == INT32_MIN) \
1102
5.43k
      OffImm = 0; \
1103
5.43k
    if (isSub) { \
1104
2.20k
      SStream_concat(O, "%s%s", ", ", markup("<imm:")); \
1105
2.20k
      printInt32Bang(O, OffImm); \
1106
2.20k
      SStream_concat0(O, markup(">")); \
1107
3.22k
    } else if (AlwaysPrintImm0 || OffImm > 0) { \
1108
3.14k
      SStream_concat(O, "%s%s", ", ", markup("<imm:")); \
1109
3.14k
      printInt32Bang(O, OffImm); \
1110
3.14k
      SStream_concat0(O, markup(">")); \
1111
3.14k
    } \
1112
5.43k
    SStream_concat(O, "%s", "]"); \
1113
5.43k
    SStream_concat0(O, markup(">")); \
1114
5.43k
  }
1115
2.85k
DEFINE_printAddrModeImm12Operand(false);
1116
2.57k
DEFINE_printAddrModeImm12Operand(true);
1117
1118
#define DEFINE_printT2AddrModeImm8Operand(AlwaysPrintImm0) \
1119
  static inline void CONCAT(printT2AddrModeImm8Operand, \
1120
          AlwaysPrintImm0)(MCInst * MI, \
1121
               unsigned OpNum, SStream *O) \
1122
6.63k
  { \
1123
6.63k
    ARM_add_cs_detail_1(MI, \
1124
6.63k
            CONCAT(ARM_OP_GROUP_T2AddrModeImm8Operand, \
1125
6.63k
             AlwaysPrintImm0), \
1126
6.63k
            OpNum, AlwaysPrintImm0); \
1127
6.63k
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
1128
6.63k
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
1129
6.63k
\
1130
6.63k
    SStream_concat(O, "%s", markup("<mem:")); \
1131
6.63k
    SStream_concat0(O, "["); \
1132
6.63k
    printRegName(O, MCOperand_getReg(MO1)); \
1133
6.63k
\
1134
6.63k
    int32_t OffImm = (int32_t)MCOperand_getImm(MO2); \
1135
6.63k
    bool isSub = OffImm < 0; \
1136
6.63k
\
1137
6.63k
    if (OffImm == INT32_MIN) \
1138
6.63k
      OffImm = 0; \
1139
6.63k
    if (isSub) { \
1140
3.69k
      SStream_concat(O, "%s%s", ", ", markup("<imm:")); \
1141
3.69k
      printInt32Bang(O, OffImm); \
1142
3.69k
      SStream_concat0(O, markup(">")); \
1143
3.69k
    } else if (AlwaysPrintImm0 || OffImm > 0) { \
1144
2.18k
      SStream_concat(O, "%s%s", ", ", markup("<imm:")); \
1145
2.18k
      printInt32Bang(O, OffImm); \
1146
2.18k
      SStream_concat0(O, markup(">")); \
1147
2.18k
    } \
1148
6.63k
    SStream_concat(O, "%s", "]"); \
1149
6.63k
    SStream_concat0(O, markup(">")); \
1150
6.63k
  }
1151
2.21k
DEFINE_printT2AddrModeImm8Operand(true);
1152
4.42k
DEFINE_printT2AddrModeImm8Operand(false);
1153
1154
#define DEFINE_printT2AddrModeImm8s4Operand(AlwaysPrintImm0) \
1155
  static inline void CONCAT(printT2AddrModeImm8s4Operand, \
1156
          AlwaysPrintImm0)(MCInst * MI, \
1157
               unsigned OpNum, SStream *O) \
1158
4.65k
  { \
1159
4.65k
    ARM_add_cs_detail_1( \
1160
4.65k
      MI, \
1161
4.65k
      CONCAT(ARM_OP_GROUP_T2AddrModeImm8s4Operand, \
1162
4.65k
             AlwaysPrintImm0), \
1163
4.65k
      OpNum, AlwaysPrintImm0); \
1164
4.65k
    MCOperand *MO1 = MCInst_getOperand(MI, (OpNum)); \
1165
4.65k
    MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1)); \
1166
4.65k
\
1167
4.65k
    if (!MCOperand_isReg(MO1)) { \
1168
0
      printOperand(MI, OpNum, O); \
1169
0
      return; \
1170
0
    } \
1171
4.65k
\
1172
4.65k
    SStream_concat(O, "%s", markup("<mem:")); \
1173
4.65k
    SStream_concat0(O, "["); \
1174
4.65k
    printRegName(O, MCOperand_getReg(MO1)); \
1175
4.65k
\
1176
4.65k
    int32_t OffImm = (int32_t)MCOperand_getImm(MO2); \
1177
4.65k
    bool isSub = OffImm < 0; \
1178
4.65k
\
1179
4.65k
    if (OffImm == INT32_MIN) \
1180
4.65k
      OffImm = 0; \
1181
4.65k
    if (isSub) { \
1182
1.71k
      SStream_concat(O, "%s%s", ", ", markup("<imm:")); \
1183
1.71k
      printInt32Bang(O, OffImm); \
1184
1.71k
      SStream_concat0(O, markup(">")); \
1185
2.93k
    } else if (AlwaysPrintImm0 || OffImm > 0) { \
1186
2.91k
      SStream_concat(O, "%s%s", ", ", markup("<imm:")); \
1187
2.91k
      printInt32Bang(O, OffImm); \
1188
2.91k
      SStream_concat0(O, markup(">")); \
1189
2.91k
    } \
1190
4.65k
    SStream_concat(O, "%s", "]"); \
1191
4.65k
    SStream_concat0(O, markup(">")); \
1192
4.65k
  }
1193
1194
855
DEFINE_printT2AddrModeImm8s4Operand(false);
1195
3.79k
DEFINE_printT2AddrModeImm8s4Operand(true);
1196
1197
static inline void printT2AddrModeImm0_1020s4Operand(MCInst *MI, unsigned OpNum,
1198
                 SStream *O)
1199
495
{
1200
495
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_T2AddrModeImm0_1020s4Operand,
1201
495
          OpNum);
1202
495
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
1203
495
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
1204
1205
495
  SStream_concat(O, "%s", markup("<mem:"));
1206
495
  SStream_concat0(O, "[");
1207
495
  printRegName(O, MCOperand_getReg(MO1));
1208
495
  if (MCOperand_getImm(MO2)) {
1209
471
    SStream_concat(O, "%s%s", ", ", markup("<imm:"));
1210
471
    printInt64Bang(O, (int32_t)(MCOperand_getImm(MO2) * 4));
1211
471
    SStream_concat0(O, markup(">"));
1212
471
  }
1213
495
  SStream_concat(O, "%s", "]");
1214
495
  SStream_concat0(O, markup(">"));
1215
495
}
1216
1217
static inline void printT2AddrModeImm8OffsetOperand(MCInst *MI, unsigned OpNum,
1218
                SStream *O)
1219
1.52k
{
1220
1.52k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_T2AddrModeImm8OffsetOperand,
1221
1.52k
          OpNum);
1222
1.52k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
1223
1.52k
  int32_t OffImm = (int32_t)MCOperand_getImm(MO1);
1224
1.52k
  SStream_concat(O, "%s", ", ");
1225
1.52k
  SStream_concat0(O, markup("<imm:"));
1226
1.52k
  if (OffImm == INT32_MIN)
1227
331
    SStream_concat0(O, "#-0");
1228
1.19k
  else if (OffImm < 0) {
1229
336
    printInt32Bang(O, OffImm);
1230
861
  } else {
1231
861
    printInt32Bang(O, OffImm);
1232
861
  }
1233
1.52k
  SStream_concat0(O, markup(">"));
1234
1.52k
}
1235
1236
static inline void
1237
printT2AddrModeImm8s4OffsetOperand(MCInst *MI, unsigned OpNum, SStream *O)
1238
1.41k
{
1239
1.41k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_T2AddrModeImm8s4OffsetOperand,
1240
1.41k
          OpNum);
1241
1.41k
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
1242
1.41k
  int32_t OffImm = (int32_t)MCOperand_getImm(MO1);
1243
1244
1.41k
  SStream_concat(O, "%s", ", ");
1245
1.41k
  SStream_concat0(O, markup("<imm:"));
1246
1.41k
  if (OffImm == INT32_MIN)
1247
399
    SStream_concat0(O, "#-0");
1248
1.01k
  else if (OffImm < 0) {
1249
440
    printInt32Bang(O, OffImm);
1250
573
  } else {
1251
573
    printInt32Bang(O, OffImm);
1252
573
  }
1253
1.41k
  SStream_concat0(O, markup(">"));
1254
1.41k
}
1255
1256
static inline void printT2AddrModeSoRegOperand(MCInst *MI, unsigned OpNum,
1257
                 SStream *O)
1258
969
{
1259
969
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_T2AddrModeSoRegOperand, OpNum);
1260
969
  MCOperand *MO1 = MCInst_getOperand(MI, (OpNum));
1261
969
  MCOperand *MO2 = MCInst_getOperand(MI, (OpNum + 1));
1262
969
  MCOperand *MO3 = MCInst_getOperand(MI, (OpNum + 2));
1263
1264
969
  SStream_concat(O, "%s", markup("<mem:"));
1265
969
  SStream_concat0(O, "[");
1266
969
  printRegName(O, MCOperand_getReg(MO1));
1267
1268
969
  SStream_concat0(O, ", ");
1269
969
  printRegName(O, MCOperand_getReg(MO2));
1270
1271
969
  unsigned ShAmt = MCOperand_getImm(MO3);
1272
969
  if (ShAmt) {
1273
273
    SStream_concat(O, "%s%s%s", ", lsl ", markup("<imm:"), "#");
1274
273
    printUInt32(O, ShAmt);
1275
273
    SStream_concat0(O, markup(">"));
1276
273
  }
1277
969
  SStream_concat(O, "%s", "]");
1278
969
  SStream_concat0(O, markup(">"));
1279
969
}
1280
1281
static inline void printFPImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1282
340
{
1283
340
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_FPImmOperand, OpNum);
1284
340
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
1285
340
  SStream_concat(O, "%s", markup("<imm:"));
1286
340
  printFloatBang(O, ARM_AM_getFPImmFloat(MCOperand_getImm(MO)));
1287
340
  SStream_concat0(O, markup(">"));
1288
340
}
1289
1290
static inline void printVMOVModImmOperand(MCInst *MI, unsigned OpNum,
1291
            SStream *O)
1292
3.83k
{
1293
3.83k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VMOVModImmOperand, OpNum);
1294
3.83k
  unsigned EncodedImm = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1295
3.83k
  unsigned EltBits;
1296
3.83k
  uint64_t Val = ARM_AM_decodeVMOVModImm(EncodedImm, &EltBits);
1297
3.83k
  SStream_concat(O, "%s", markup("<imm:"));
1298
3.83k
  printUInt64Bang(O, Val);
1299
3.83k
  SStream_concat0(O, markup(">"));
1300
3.83k
}
1301
1302
static inline void printImmPlusOneOperand(MCInst *MI, unsigned OpNum,
1303
            SStream *O)
1304
1.01k
{
1305
1.01k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ImmPlusOneOperand, OpNum);
1306
1.01k
  unsigned Imm = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1307
1.01k
  SStream_concat(O, "%s", markup("<imm:"));
1308
1.01k
  printUInt32Bang(O, Imm + 1);
1309
1.01k
  SStream_concat0(O, markup(">"));
1310
1.01k
}
1311
1312
static inline void printRotImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1313
528
{
1314
528
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_RotImmOperand, OpNum);
1315
528
  unsigned Imm = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1316
528
  if (Imm == 0)
1317
112
    return;
1318
1319
416
  SStream_concat(O, "%s%s%s%d", ", ror ", markup("<imm:"), "#", 8 * Imm);
1320
416
  SStream_concat0(O, markup(">"));
1321
416
}
1322
1323
static inline void printModImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
1324
4.23k
{
1325
4.23k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_ModImmOperand, OpNum);
1326
4.23k
  MCOperand *Op = MCInst_getOperand(MI, (OpNum));
1327
1328
  // Support for fixups (MCFixup)
1329
4.23k
  if (MCOperand_isExpr(Op)) {
1330
0
    printOperand(MI, OpNum, O);
1331
0
    return;
1332
0
  }
1333
1334
4.23k
  unsigned Bits = MCOperand_getImm(Op) & 0xFF;
1335
4.23k
  unsigned Rot = (MCOperand_getImm(Op) & 0xF00) >> 7;
1336
1337
4.23k
  bool PrintUnsigned = false;
1338
4.23k
  switch (MCInst_getOpcode(MI)) {
1339
303
  case ARM_MOVi:
1340
    // Movs to PC should be treated unsigned
1341
303
    PrintUnsigned =
1342
303
      (MCOperand_getReg(MCInst_getOperand(MI, (OpNum - 1))) ==
1343
303
       ARM_PC);
1344
303
    break;
1345
255
  case ARM_MSRi:
1346
    // Movs to special registers should be treated unsigned
1347
255
    PrintUnsigned = true;
1348
255
    break;
1349
4.23k
  }
1350
1351
4.23k
  int32_t Rotated = ARM_AM_rotr32(Bits, Rot);
1352
4.23k
  if (ARM_AM_getSOImmVal(Rotated) == MCOperand_getImm(Op)) {
1353
    // #rot has the least possible value
1354
3.17k
    SStream_concat(O, "%s", "#");
1355
3.17k
    SStream_concat0(O, markup("<imm:"));
1356
3.17k
    if (PrintUnsigned)
1357
182
      printUInt32(O, (uint32_t)(Rotated));
1358
2.98k
    else
1359
2.98k
      printInt32(O, Rotated);
1360
3.17k
    SStream_concat0(O, markup(">"));
1361
3.17k
    return;
1362
3.17k
  }
1363
1364
  // Explicit #bits, #rot implied
1365
1.06k
  SStream_concat(O, "%s%s%u", "#", markup("<imm:"), Bits);
1366
1.06k
  SStream_concat(O, "%s%s%s%u", markup(">"), ", #", markup("<imm:"), Rot);
1367
1.06k
  SStream_concat0(O, markup(">"));
1368
1.06k
}
1369
1370
static inline void printFBits16(MCInst *MI, unsigned OpNum, SStream *O)
1371
323
{
1372
323
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_FBits16, OpNum);
1373
323
  SStream_concat(O, "%s%s", markup("<imm:"), "#");
1374
323
  SStream_concat(O, "%" PRIu32,
1375
323
           (uint32_t)(16 - MCOperand_getImm(MCInst_getOperand(
1376
323
                 MI, (OpNum)))));
1377
323
  SStream_concat0(O, markup(">"));
1378
323
}
1379
1380
static inline void printFBits32(MCInst *MI, unsigned OpNum, SStream *O)
1381
144
{
1382
144
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_FBits32, OpNum);
1383
144
  SStream_concat(O, "%s%s", markup("<imm:"), "#");
1384
144
  printInt64(O, 32 - MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
1385
144
  SStream_concat0(O, markup(">"));
1386
144
}
1387
1388
static inline void printVectorIndex(MCInst *MI, unsigned OpNum, SStream *O)
1389
4.18k
{
1390
4.18k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorIndex, OpNum);
1391
4.18k
  SStream_concat(O, "%s", "[");
1392
4.18k
  printInt64(O,
1393
4.18k
       (int32_t)MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
1394
4.18k
  SStream_concat0(O, "]");
1395
4.18k
}
1396
1397
static inline void printVectorListOne(MCInst *MI, unsigned OpNum, SStream *O)
1398
1.90k
{
1399
1.90k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListOne, OpNum);
1400
1.90k
  SStream_concat0(O, "{");
1401
1.90k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1402
1.90k
  SStream_concat0(O, "}");
1403
1.90k
}
1404
1405
static inline void printVectorListTwo(MCInst *MI, unsigned OpNum, SStream *O)
1406
3.48k
{
1407
3.48k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListTwo, OpNum);
1408
3.48k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
1409
3.48k
  unsigned Reg0 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_0);
1410
3.48k
  unsigned Reg1 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_1);
1411
3.48k
  SStream_concat0(O, "{");
1412
3.48k
  printRegName(O, Reg0);
1413
3.48k
  SStream_concat0(O, ", ");
1414
3.48k
  printRegName(O, Reg1);
1415
3.48k
  SStream_concat0(O, "}");
1416
3.48k
}
1417
1418
static inline void printVectorListTwoSpaced(MCInst *MI, unsigned OpNum,
1419
              SStream *O)
1420
3.10k
{
1421
3.10k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListTwoSpaced, OpNum);
1422
3.10k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
1423
3.10k
  unsigned Reg0 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_0);
1424
3.10k
  unsigned Reg1 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_2);
1425
3.10k
  SStream_concat0(O, "{");
1426
3.10k
  printRegName(O, Reg0);
1427
3.10k
  SStream_concat0(O, ", ");
1428
3.10k
  printRegName(O, Reg1);
1429
3.10k
  SStream_concat0(O, "}");
1430
3.10k
}
1431
1432
static inline void printVectorListThree(MCInst *MI, unsigned OpNum, SStream *O)
1433
2.15k
{
1434
2.15k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListThree, OpNum);
1435
  // Normally, it's not safe to use register enum values directly with
1436
  // addition to get the next register, but for VFP registers, the
1437
  // sort order is guaranteed because they're all of the form D<n>.
1438
2.15k
  SStream_concat0(O, "{");
1439
2.15k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1440
2.15k
  SStream_concat0(O, ", ");
1441
2.15k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 1);
1442
2.15k
  SStream_concat0(O, ", ");
1443
2.15k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1444
2.15k
  SStream_concat0(O, "}");
1445
2.15k
}
1446
1447
static inline void printVectorListFour(MCInst *MI, unsigned OpNum, SStream *O)
1448
3.06k
{
1449
3.06k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListFour, OpNum);
1450
  // Normally, it's not safe to use register enum values directly with
1451
  // addition to get the next register, but for VFP registers, the
1452
  // sort order is guaranteed because they're all of the form D<n>.
1453
3.06k
  SStream_concat0(O, "{");
1454
3.06k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1455
3.06k
  SStream_concat0(O, ", ");
1456
3.06k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 1);
1457
3.06k
  SStream_concat0(O, ", ");
1458
3.06k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1459
3.06k
  SStream_concat0(O, ", ");
1460
3.06k
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 3);
1461
3.06k
  SStream_concat0(O, "}");
1462
3.06k
}
1463
1464
static inline void printVectorListOneAllLanes(MCInst *MI, unsigned OpNum,
1465
                SStream *O)
1466
695
{
1467
695
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListOneAllLanes, OpNum);
1468
695
  SStream_concat0(O, "{");
1469
695
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1470
695
  SStream_concat0(O, "[]}");
1471
695
}
1472
1473
static inline void printVectorListTwoAllLanes(MCInst *MI, unsigned OpNum,
1474
                SStream *O)
1475
1.04k
{
1476
1.04k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListTwoAllLanes, OpNum);
1477
1.04k
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
1478
1.04k
  unsigned Reg0 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_0);
1479
1.04k
  unsigned Reg1 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_1);
1480
1.04k
  SStream_concat0(O, "{");
1481
1.04k
  printRegName(O, Reg0);
1482
1.04k
  SStream_concat0(O, "[], ");
1483
1.04k
  printRegName(O, Reg1);
1484
1.04k
  SStream_concat0(O, "[]}");
1485
1.04k
}
1486
1487
static inline void printVectorListThreeAllLanes(MCInst *MI, unsigned OpNum,
1488
            SStream *O)
1489
0
{
1490
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListThreeAllLanes, OpNum);
1491
  // Normally, it's not safe to use register enum values directly with
1492
  // addition to get the next register, but for VFP registers, the
1493
  // sort order is guaranteed because they're all of the form D<n>.
1494
0
  SStream_concat0(O, "{");
1495
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1496
0
  SStream_concat0(O, "[], ");
1497
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 1);
1498
0
  SStream_concat0(O, "[], ");
1499
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1500
0
  SStream_concat0(O, "[]}");
1501
0
}
1502
1503
static inline void printVectorListFourAllLanes(MCInst *MI, unsigned OpNum,
1504
                 SStream *O)
1505
0
{
1506
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListFourAllLanes, OpNum);
1507
  // Normally, it's not safe to use register enum values directly with
1508
  // addition to get the next register, but for VFP registers, the
1509
  // sort order is guaranteed because they're all of the form D<n>.
1510
0
  SStream_concat0(O, "{");
1511
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1512
0
  SStream_concat0(O, "[], ");
1513
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 1);
1514
0
  SStream_concat0(O, "[], ");
1515
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1516
0
  SStream_concat0(O, "[], ");
1517
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 3);
1518
0
  SStream_concat0(O, "[]}");
1519
0
}
1520
1521
static inline void printVectorListTwoSpacedAllLanes(MCInst *MI, unsigned OpNum,
1522
                SStream *O)
1523
759
{
1524
759
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListTwoSpacedAllLanes,
1525
759
          OpNum);
1526
759
  unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
1527
759
  unsigned Reg0 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_0);
1528
759
  unsigned Reg1 = MCRegisterInfo_getSubReg(MI->MRI, Reg, ARM_dsub_2);
1529
759
  SStream_concat0(O, "{");
1530
759
  printRegName(O, Reg0);
1531
759
  SStream_concat0(O, "[], ");
1532
759
  printRegName(O, Reg1);
1533
759
  SStream_concat0(O, "[]}");
1534
759
}
1535
1536
static inline void
1537
printVectorListThreeSpacedAllLanes(MCInst *MI, unsigned OpNum, SStream *O)
1538
0
{
1539
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListThreeSpacedAllLanes,
1540
0
          OpNum);
1541
  // Normally, it's not safe to use register enum values directly with
1542
  // addition to get the next register, but for VFP registers, the
1543
  // sort order is guaranteed because they're all of the form D<n>.
1544
0
  SStream_concat0(O, "{");
1545
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1546
0
  SStream_concat0(O, "[], ");
1547
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1548
0
  SStream_concat0(O, "[], ");
1549
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 4);
1550
0
  SStream_concat0(O, "[]}");
1551
0
}
1552
1553
static inline void printVectorListFourSpacedAllLanes(MCInst *MI, unsigned OpNum,
1554
                 SStream *O)
1555
0
{
1556
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListFourSpacedAllLanes,
1557
0
          OpNum);
1558
  // Normally, it's not safe to use register enum values directly with
1559
  // addition to get the next register, but for VFP registers, the
1560
  // sort order is guaranteed because they're all of the form D<n>.
1561
0
  SStream_concat0(O, "{");
1562
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1563
0
  SStream_concat0(O, "[], ");
1564
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1565
0
  SStream_concat0(O, "[], ");
1566
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 4);
1567
0
  SStream_concat0(O, "[], ");
1568
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 6);
1569
0
  SStream_concat0(O, "[]}");
1570
0
}
1571
1572
static inline void printVectorListThreeSpaced(MCInst *MI, unsigned OpNum,
1573
                SStream *O)
1574
0
{
1575
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListThreeSpaced, OpNum);
1576
  // Normally, it's not safe to use register enum values directly with
1577
  // addition to get the next register, but for VFP registers, the
1578
  // sort order is guaranteed because they're all of the form D<n>.
1579
0
  SStream_concat0(O, "{");
1580
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1581
0
  SStream_concat0(O, ", ");
1582
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1583
0
  SStream_concat0(O, ", ");
1584
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 4);
1585
0
  SStream_concat0(O, "}");
1586
0
}
1587
1588
static inline void printVectorListFourSpaced(MCInst *MI, unsigned OpNum,
1589
               SStream *O)
1590
0
{
1591
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VectorListFourSpaced, OpNum);
1592
  // Normally, it's not safe to use register enum values directly with
1593
  // addition to get the next register, but for VFP registers, the
1594
  // sort order is guaranteed because they're all of the form D<n>.
1595
0
  SStream_concat0(O, "{");
1596
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))));
1597
0
  SStream_concat0(O, ", ");
1598
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 2);
1599
0
  SStream_concat0(O, ", ");
1600
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 4);
1601
0
  SStream_concat0(O, ", ");
1602
0
  printRegName(O, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))) + 6);
1603
0
  SStream_concat0(O, "}");
1604
0
}
1605
1606
#define DEFINE_printMVEVectorList(NumRegs) \
1607
  static inline void CONCAT(printMVEVectorList, NumRegs)( \
1608
    MCInst * MI, unsigned OpNum, SStream *O) \
1609
1.66k
  { \
1610
1.66k
    ARM_add_cs_detail_1( \
1611
1.66k
      MI, CONCAT(ARM_OP_GROUP_MVEVectorList, NumRegs), \
1612
1.66k
      OpNum, NumRegs); \
1613
1.66k
    unsigned Reg = \
1614
1.66k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1615
1.66k
    const char *Prefix = "{"; \
1616
6.22k
    for (unsigned i = 0; i < NumRegs; i++) { \
1617
4.55k
      SStream_concat0(O, Prefix); \
1618
4.55k
      printRegName( \
1619
4.55k
        O, MCRegisterInfo_getSubReg(MI->MRI, Reg, \
1620
4.55k
                  ARM_qsub_0 + i)); \
1621
4.55k
      Prefix = ", "; \
1622
4.55k
    } \
1623
1.66k
    SStream_concat0(O, "}"); \
1624
1.66k
  }
ARMInstPrinter.c:printMVEVectorList_2
Line
Count
Source
1609
1.05k
  { \
1610
1.05k
    ARM_add_cs_detail_1( \
1611
1.05k
      MI, CONCAT(ARM_OP_GROUP_MVEVectorList, NumRegs), \
1612
1.05k
      OpNum, NumRegs); \
1613
1.05k
    unsigned Reg = \
1614
1.05k
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1615
1.05k
    const char *Prefix = "{"; \
1616
3.17k
    for (unsigned i = 0; i < NumRegs; i++) { \
1617
2.11k
      SStream_concat0(O, Prefix); \
1618
2.11k
      printRegName( \
1619
2.11k
        O, MCRegisterInfo_getSubReg(MI->MRI, Reg, \
1620
2.11k
                  ARM_qsub_0 + i)); \
1621
2.11k
      Prefix = ", "; \
1622
2.11k
    } \
1623
1.05k
    SStream_concat0(O, "}"); \
1624
1.05k
  }
ARMInstPrinter.c:printMVEVectorList_4
Line
Count
Source
1609
610
  { \
1610
610
    ARM_add_cs_detail_1( \
1611
610
      MI, CONCAT(ARM_OP_GROUP_MVEVectorList, NumRegs), \
1612
610
      OpNum, NumRegs); \
1613
610
    unsigned Reg = \
1614
610
      MCOperand_getReg(MCInst_getOperand(MI, (OpNum))); \
1615
610
    const char *Prefix = "{"; \
1616
3.05k
    for (unsigned i = 0; i < NumRegs; i++) { \
1617
2.44k
      SStream_concat0(O, Prefix); \
1618
2.44k
      printRegName( \
1619
2.44k
        O, MCRegisterInfo_getSubReg(MI->MRI, Reg, \
1620
2.44k
                  ARM_qsub_0 + i)); \
1621
2.44k
      Prefix = ", "; \
1622
2.44k
    } \
1623
610
    SStream_concat0(O, "}"); \
1624
610
  }
1625
DEFINE_printMVEVectorList(2) DEFINE_printMVEVectorList(4)
1626
1627
#define DEFINE_printComplexRotationOp(Angle, Remainder) \
1628
  static inline void CONCAT(printComplexRotationOp, \
1629
          CONCAT(Angle, Remainder))( \
1630
    MCInst * MI, unsigned OpNo, SStream *O) \
1631
2.22k
  { \
1632
2.22k
    ARM_add_cs_detail_2( \
1633
2.22k
      MI, \
1634
2.22k
      CONCAT(CONCAT(ARM_OP_GROUP_ComplexRotationOp, Angle), \
1635
2.22k
             Remainder), \
1636
2.22k
      OpNo, Angle, Remainder); \
1637
2.22k
    unsigned Val = \
1638
2.22k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
1639
2.22k
    SStream_concat(O, "#%u", \
1640
2.22k
             (uint32_t)((Val * Angle) + Remainder)); \
1641
2.22k
  }
ARMInstPrinter.c:printComplexRotationOp_90_0
Line
Count
Source
1631
919
  { \
1632
919
    ARM_add_cs_detail_2( \
1633
919
      MI, \
1634
919
      CONCAT(CONCAT(ARM_OP_GROUP_ComplexRotationOp, Angle), \
1635
919
             Remainder), \
1636
919
      OpNo, Angle, Remainder); \
1637
919
    unsigned Val = \
1638
919
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
1639
919
    SStream_concat(O, "#%u", \
1640
919
             (uint32_t)((Val * Angle) + Remainder)); \
1641
919
  }
ARMInstPrinter.c:printComplexRotationOp_180_90
Line
Count
Source
1631
1.30k
  { \
1632
1.30k
    ARM_add_cs_detail_2( \
1633
1.30k
      MI, \
1634
1.30k
      CONCAT(CONCAT(ARM_OP_GROUP_ComplexRotationOp, Angle), \
1635
1.30k
             Remainder), \
1636
1.30k
      OpNo, Angle, Remainder); \
1637
1.30k
    unsigned Val = \
1638
1.30k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNo))); \
1639
1.30k
    SStream_concat(O, "#%u", \
1640
1.30k
             (uint32_t)((Val * Angle) + Remainder)); \
1641
1.30k
  }
1642
  DEFINE_printComplexRotationOp(90, 0) DEFINE_printComplexRotationOp(180,
1643
                     90)
1644
1645
    static inline void printVPTPredicateOperand(MCInst *MI,
1646
                  unsigned OpNum,
1647
                  SStream *O)
1648
20.3k
{
1649
20.3k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VPTPredicateOperand, OpNum);
1650
20.3k
  ARMVCC_VPTCodes CC = (ARMVCC_VPTCodes)MCOperand_getImm(
1651
20.3k
    MCInst_getOperand(MI, (OpNum)));
1652
20.3k
  if (CC != ARMVCC_None)
1653
915
    SStream_concat0(O, ARMVPTPredToString(CC));
1654
20.3k
}
1655
1656
static inline void printVPTMask(MCInst *MI, unsigned OpNum, SStream *O)
1657
4.11k
{
1658
4.11k
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_VPTMask, OpNum);
1659
  // (3 - the number of trailing zeroes) is the number of them / else.
1660
4.11k
  unsigned Mask = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1661
4.11k
  unsigned NumTZ = CountTrailingZeros_32(Mask);
1662
1663
13.5k
  for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
1664
9.39k
    bool T = ((Mask >> Pos) & 1) == 0;
1665
9.39k
    if (T)
1666
4.75k
      SStream_concat0(O, "t");
1667
1668
4.63k
    else
1669
4.63k
      SStream_concat0(O, "e");
1670
9.39k
  }
1671
4.11k
}
1672
1673
static inline void printMveSaturateOp(MCInst *MI, unsigned OpNum, SStream *O)
1674
0
{
1675
0
  ARM_add_cs_detail_0(MI, ARM_OP_GROUP_MveSaturateOp, OpNum);
1676
0
  uint32_t Val = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
1677
1678
0
  printUInt32Bang(O, (Val == 1 ? 48 : 64));
1679
0
}
1680
1681
#define PRINT_ALIAS_INSTR
1682
#include "ARMGenAsmWriter.inc"
1683
1684
static void printInst(MCInst *MI, SStream *O, void *info)
1685
654k
{
1686
654k
  bool isAlias = false;
1687
654k
  bool useAliasDetails = map_use_alias_details(MI);
1688
654k
  map_set_fill_detail_ops(MI, useAliasDetails);
1689
654k
  unsigned Opcode = MCInst_getOpcode(MI);
1690
654k
  uint64_t Address = MI->address;
1691
1692
654k
  switch (Opcode) {
1693
  // Check for MOVs and print canonical forms, instead.
1694
152
  case ARM_MOVsr: {
1695
152
    isAlias = true;
1696
152
    MCInst_setIsAlias(MI, isAlias);
1697
    // FIXME: Thumb variants?
1698
152
    MCOperand *MO3 = MCInst_getOperand(MI, (3));
1699
1700
152
    SStream_concat1(O, ' ');
1701
152
    SStream_concat0(O, ARM_AM_getShiftOpcStr(ARM_AM_getSORegShOp(
1702
152
             MCOperand_getImm(MO3))));
1703
152
    printSBitModifierOperand(MI, 6, O);
1704
152
    printPredicateOperand(MI, 4, O);
1705
1706
152
    SStream_concat0(O, " ");
1707
1708
152
    printOperand(MI, 0, O);
1709
152
    SStream_concat0(O, ", ");
1710
152
    printOperand(MI, 1, O);
1711
1712
152
    SStream_concat0(O, ", ");
1713
152
    printOperand(MI, 2, O);
1714
1715
152
    if (useAliasDetails)
1716
152
      return;
1717
0
    else
1718
0
      goto add_real_detail;
1719
152
  }
1720
1721
694
  case ARM_MOVsi: {
1722
694
    isAlias = true;
1723
694
    MCInst_setIsAlias(MI, isAlias);
1724
    // FIXME: Thumb variants?
1725
694
    MCOperand *MO2 = MCInst_getOperand(MI, (2));
1726
1727
694
    SStream_concat0(O, ARM_AM_getShiftOpcStr(ARM_AM_getSORegShOp(
1728
694
             MCOperand_getImm(MO2))));
1729
694
    printSBitModifierOperand(MI, 5, O);
1730
694
    printPredicateOperand(MI, 3, O);
1731
1732
694
    SStream_concat0(O, " ");
1733
1734
694
    printOperand(MI, 0, O);
1735
694
    SStream_concat0(O, ", ");
1736
694
    printOperand(MI, 1, O);
1737
1738
694
    if (ARM_AM_getSORegShOp(MCOperand_getImm(MO2)) == ARM_AM_rrx) {
1739
198
      if (useAliasDetails)
1740
198
        return;
1741
0
      else
1742
0
        goto add_real_detail;
1743
198
    }
1744
1745
496
    SStream_concat(O, "%s%s%s%d", ", ", markup("<imm:"), "#",
1746
496
             translateShiftImm(ARM_AM_getSORegOffset(
1747
496
               MCOperand_getImm(MO2))));
1748
496
    SStream_concat0(O, markup(">"));
1749
496
    if (useAliasDetails)
1750
496
      return;
1751
0
    else
1752
0
      goto add_real_detail;
1753
496
  }
1754
1755
  // A8.6.123 PUSH
1756
144
  case ARM_STMDB_UPD:
1757
259
  case ARM_t2STMDB_UPD:
1758
259
    if (MCOperand_getReg(MCInst_getOperand(MI, (0))) == ARM_SP &&
1759
177
        MCInst_getNumOperands(MI) > 5) {
1760
136
      isAlias = true;
1761
136
      MCInst_setIsAlias(MI, isAlias);
1762
      // Should only print PUSH if there are at least two registers in the
1763
      // list.
1764
136
      SStream_concat0(O, "push");
1765
136
      printPredicateOperand(MI, 2, O);
1766
136
      if (Opcode == ARM_t2STMDB_UPD)
1767
71
        SStream_concat0(O, ".w");
1768
136
      SStream_concat0(O, " ");
1769
1770
136
      printRegisterList(MI, 4, O);
1771
136
      if (useAliasDetails)
1772
136
        return;
1773
0
      else
1774
0
        goto add_real_detail;
1775
136
    } else
1776
123
      break;
1777
1778
670
  case ARM_STR_PRE_IMM:
1779
670
    if (MCOperand_getReg(MCInst_getOperand(MI, (2))) == ARM_SP &&
1780
52
        MCOperand_getImm(MCInst_getOperand(MI, (3))) == -4) {
1781
0
      isAlias = true;
1782
0
      MCInst_setIsAlias(MI, isAlias);
1783
0
      SStream_concat1(O, ' ');
1784
0
      SStream_concat0(O, "push");
1785
0
      printPredicateOperand(MI, 4, O);
1786
0
      SStream_concat0(O, " {");
1787
0
      printOperand(MI, 1, O);
1788
0
      SStream_concat0(O, "}");
1789
0
      if (useAliasDetails)
1790
0
        return;
1791
0
      else
1792
0
        goto add_real_detail;
1793
0
    } else
1794
670
      break;
1795
1796
  // A8.6.122 POP
1797
185
  case ARM_LDMIA_UPD:
1798
646
  case ARM_t2LDMIA_UPD:
1799
646
    if (MCOperand_getReg(MCInst_getOperand(MI, (0))) == ARM_SP &&
1800
234
        MCInst_getNumOperands(MI) > 5) {
1801
181
      isAlias = true;
1802
181
      MCInst_setIsAlias(MI, isAlias);
1803
      // Should only print POP if there are at least two registers in the
1804
      // list.
1805
181
      SStream_concat0(O, "pop");
1806
181
      printPredicateOperand(MI, 2, O);
1807
181
      if (Opcode == ARM_t2LDMIA_UPD)
1808
81
        SStream_concat0(O, ".w");
1809
181
      SStream_concat0(O, " ");
1810
1811
181
      printRegisterList(MI, 4, O);
1812
181
      if (useAliasDetails)
1813
181
        return;
1814
0
      else
1815
0
        goto add_real_detail;
1816
181
    } else
1817
465
      break;
1818
1819
433
  case ARM_LDR_POST_IMM:
1820
433
    if ((MCOperand_getReg(MCInst_getOperand(MI, (2))) == ARM_SP) &&
1821
209
        ((ARM_AM_getAM2Offset(MCOperand_getImm(
1822
209
            MCInst_getOperand(MI, (4)))) == 4))) {
1823
130
      isAlias = true;
1824
130
      MCInst_setIsAlias(MI, isAlias);
1825
130
      SStream_concat0(O, "pop");
1826
130
      printPredicateOperand(MI, 5, O);
1827
130
      SStream_concat0(O, " {");
1828
130
      printOperand(MI, 0, O);
1829
130
      SStream_concat0(O, "}");
1830
130
      if (useAliasDetails)
1831
130
        return;
1832
0
      else
1833
0
        goto add_real_detail;
1834
130
    } else
1835
303
      break;
1836
116
  case ARM_t2LDR_POST:
1837
116
    if ((MCOperand_getReg(MCInst_getOperand(MI, (2))) == ARM_SP) &&
1838
51
        (Opcode == ARM_t2LDR_POST &&
1839
51
         (MCOperand_getImm(MCInst_getOperand(MI, (3))) == 4))) {
1840
32
      isAlias = true;
1841
32
      MCInst_setIsAlias(MI, isAlias);
1842
32
      SStream_concat0(O, "pop");
1843
32
      printPredicateOperand(MI, 4, O);
1844
32
      SStream_concat0(O, " {");
1845
32
      printOperand(MI, 0, O);
1846
32
      SStream_concat0(O, "}");
1847
32
      if (useAliasDetails)
1848
32
        return;
1849
0
      else
1850
0
        goto add_real_detail;
1851
32
    } else
1852
84
      break;
1853
1854
  // A8.6.355 VPUSH
1855
67
  case ARM_VSTMSDB_UPD:
1856
122
  case ARM_VSTMDDB_UPD:
1857
122
    if (MCOperand_getReg(MCInst_getOperand(MI, (0))) == ARM_SP) {
1858
11
      isAlias = true;
1859
11
      MCInst_setIsAlias(MI, isAlias);
1860
11
      SStream_concat0(O, "vpush");
1861
11
      printPredicateOperand(MI, 2, O);
1862
11
      SStream_concat0(O, " ");
1863
1864
11
      printRegisterList(MI, 4, O);
1865
11
      if (useAliasDetails)
1866
11
        return;
1867
0
      else
1868
0
        goto add_real_detail;
1869
11
    } else
1870
111
      break;
1871
1872
  // A8.6.354 VPOP
1873
91
  case ARM_VLDMSIA_UPD:
1874
264
  case ARM_VLDMDIA_UPD:
1875
264
    if (MCOperand_getReg(MCInst_getOperand(MI, (0))) == ARM_SP) {
1876
66
      isAlias = true;
1877
66
      MCInst_setIsAlias(MI, isAlias);
1878
66
      SStream_concat1(O, ' ');
1879
66
      SStream_concat0(O, "vpop");
1880
66
      printPredicateOperand(MI, 2, O);
1881
66
      SStream_concat0(O, " ");
1882
1883
66
      printRegisterList(MI, 4, O);
1884
66
      if (useAliasDetails)
1885
66
        return;
1886
0
      else
1887
0
        goto add_real_detail;
1888
66
    } else
1889
198
      break;
1890
1891
7.30k
  case ARM_tLDMIA: {
1892
7.30k
    isAlias = true;
1893
7.30k
    MCInst_setIsAlias(MI, isAlias);
1894
7.30k
    bool Writeback = true;
1895
7.30k
    unsigned BaseReg = MCOperand_getReg(MCInst_getOperand(MI, (0)));
1896
40.4k
    for (unsigned i = 3; i < MCInst_getNumOperands(MI); ++i) {
1897
33.1k
      if (MCOperand_getReg(MCInst_getOperand(MI, (i))) ==
1898
33.1k
          BaseReg)
1899
3.72k
        Writeback = false;
1900
33.1k
    }
1901
1902
7.30k
    SStream_concat0(O, "ldm");
1903
1904
7.30k
    printPredicateOperand(MI, 1, O);
1905
7.30k
    SStream_concat0(O, " ");
1906
1907
7.30k
    printOperand(MI, 0, O);
1908
7.30k
    if (Writeback) {
1909
3.57k
      SStream_concat0(O, "!");
1910
3.57k
    }
1911
7.30k
    SStream_concat0(O, ", ");
1912
7.30k
    printRegisterList(MI, 3, O);
1913
7.30k
    if (useAliasDetails)
1914
7.30k
      return;
1915
0
    else
1916
0
      goto add_real_detail;
1917
7.30k
  }
1918
1919
  // Combine 2 GPRs from disassember into a GPRPair to match with instr def.
1920
  // ldrexd/strexd require even/odd GPR pair. To enforce this constraint,
1921
  // a single GPRPair reg operand is used in the .td file to replace the two
1922
  // GPRs. However, when decoding them, the two GRPs cannot be automatically
1923
  // expressed as a GPRPair, so we have to manually merge them.
1924
  // FIXME: We would really like to be able to tablegen'erate this.
1925
298
  case ARM_LDREXD:
1926
414
  case ARM_STREXD:
1927
464
  case ARM_LDAEXD:
1928
556
  case ARM_STLEXD: {
1929
556
    const MCRegisterClass *MRC =
1930
556
      MCRegisterInfo_getRegClass(MI->MRI, ARM_GPRRegClassID);
1931
556
    bool isStore = Opcode == ARM_STREXD || Opcode == ARM_STLEXD;
1932
556
    unsigned Reg = MCOperand_getReg(
1933
556
      MCInst_getOperand(MI, isStore ? 1 : 0));
1934
1935
556
    if (MCRegisterClass_contains(MRC, Reg)) {
1936
0
      MCInst NewMI;
1937
1938
0
      MCInst_Init(&NewMI, CS_ARCH_ARM);
1939
0
      MCInst_setOpcode(&NewMI, Opcode);
1940
1941
0
      if (isStore)
1942
0
        MCInst_addOperand2(&NewMI,
1943
0
               MCInst_getOperand(MI, 0));
1944
1945
0
      MCOperand_CreateReg0(
1946
0
        &NewMI,
1947
0
        MCRegisterInfo_getMatchingSuperReg(
1948
0
          MI->MRI, Reg, ARM_gsub_0,
1949
0
          MCRegisterInfo_getRegClass(
1950
0
            MI->MRI,
1951
0
            ARM_GPRPairRegClassID)));
1952
1953
      // Copy the rest operands into NewMI.
1954
0
      for (unsigned i = isStore ? 3 : 2;
1955
0
           i < MCInst_getNumOperands(MI); ++i)
1956
0
        MCInst_addOperand2(&NewMI,
1957
0
               MCInst_getOperand(MI, i));
1958
1959
0
      printInstruction(&NewMI, Address, O);
1960
0
      return;
1961
0
    }
1962
556
    break;
1963
556
  }
1964
556
  case ARM_TSB:
1965
73
  case ARM_t2TSB:
1966
73
    isAlias = true;
1967
73
    MCInst_setIsAlias(MI, isAlias);
1968
1969
73
    SStream_concat0(O, " tsb csync");
1970
73
    if (useAliasDetails)
1971
73
      return;
1972
0
    else
1973
0
      goto add_real_detail;
1974
536
  case ARM_t2DSB:
1975
536
    isAlias = true;
1976
536
    MCInst_setIsAlias(MI, isAlias);
1977
1978
536
    switch (MCOperand_getImm(MCInst_getOperand(MI, (0)))) {
1979
343
    default:
1980
343
      if (!printAliasInstr(MI, Address, O))
1981
343
        printInstruction(MI, Address, O);
1982
343
      break;
1983
101
    case 0:
1984
101
      SStream_concat0(O, " ssbb");
1985
101
      break;
1986
92
    case 4:
1987
92
      SStream_concat0(O, " pssbb");
1988
92
      break;
1989
536
    };
1990
536
    if (useAliasDetails)
1991
536
      return;
1992
0
    else
1993
0
      goto add_real_detail;
1994
654k
  }
1995
1996
645k
  if (!isAlias)
1997
645k
    isAlias |= printAliasInstr(MI, Address, O);
1998
1999
645k
add_real_detail:
2000
645k
  MCInst_setIsAlias(MI, isAlias);
2001
645k
  if (!isAlias || !useAliasDetails) {
2002
643k
    map_set_fill_detail_ops(MI, !(isAlias && useAliasDetails));
2003
643k
    if (isAlias)
2004
0
      SStream_Close(O);
2005
643k
    printInstruction(MI, Address, O);
2006
643k
    if (isAlias)
2007
0
      SStream_Open(O);
2008
643k
  }
2009
645k
}
2010
2011
const char *ARM_LLVM_getRegisterName(unsigned RegNo, unsigned AltIdx)
2012
419k
{
2013
419k
  return getRegisterName(RegNo, AltIdx);
2014
419k
}
2015
2016
void ARM_LLVM_printInstruction(MCInst *MI, SStream *O,
2017
             void * /* MCRegisterInfo* */ info)
2018
654k
{
2019
654k
  printInst(MI, O, info);
2020
654k
}