Coverage Report

Created: 2026-03-11 06:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonenext/arch/SystemZ/SystemZInstPrinter.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
//===- SystemZInstPrinter.cpp - Convert SystemZ 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
#include <ctype.h>
24
#include <stdint.h>
25
#include <stdio.h>
26
#include <string.h>
27
#include <stdlib.h>
28
#include <capstone/platform.h>
29
30
#include "../../MathExtras.h"
31
#include "../../MCAsmInfo.h"
32
33
#include "SystemZMapping.h"
34
#include "SystemZInstPrinter.h"
35
36
32.0k
#define CONCAT(a, b) CONCAT_(a, b)
37
32.0k
#define CONCAT_(a, b) a##_##b
38
39
static void printAddress(const MCAsmInfo *MAI, MCRegister Base,
40
       const MCOperand *DispMO, MCRegister Index, SStream *O);
41
static void printMCOperandMAI(const MCOperand *MO, const MCAsmInfo *MAI,
42
            SStream *O);
43
static void printRegName(const MCInst *MI, SStream *O, MCRegister Reg);
44
static void printInst(MCInst *MI, uint64_t Address, const char *Annot,
45
          SStream *O);
46
static void printOperand(MCInst *MI, int OpNum, SStream *O);
47
static void printU1ImmOperand(MCInst *MI, int OpNum, SStream *O);
48
static void printU2ImmOperand(MCInst *MI, int OpNum, SStream *O);
49
static void printU3ImmOperand(MCInst *MI, int OpNum, SStream *O);
50
static void printU4ImmOperand(MCInst *MI, int OpNum, SStream *O);
51
static void printS8ImmOperand(MCInst *MI, int OpNum, SStream *O);
52
static void printU8ImmOperand(MCInst *MI, int OpNum, SStream *O);
53
static void printU12ImmOperand(MCInst *MI, int OpNum, SStream *O);
54
static void printS16ImmOperand(MCInst *MI, int OpNum, SStream *O);
55
static void printU16ImmOperand(MCInst *MI, int OpNum, SStream *O);
56
static void printS32ImmOperand(MCInst *MI, int OpNum, SStream *O);
57
static void printU32ImmOperand(MCInst *MI, int OpNum, SStream *O);
58
static void printU48ImmOperand(MCInst *MI, int OpNum, SStream *O);
59
static void printBDAddrOperand(MCInst *MI, int OpNum, SStream *O);
60
static void printBDXAddrOperand(MCInst *MI, int OpNum, SStream *O);
61
static void printBDLAddrOperand(MCInst *MI, int OpNum, SStream *O);
62
static void printBDRAddrOperand(MCInst *MI, int OpNum, SStream *O);
63
static void printBDVAddrOperand(MCInst *MI, int OpNum, SStream *O);
64
static void printPCRelOperand(MCInst *MI, uint64_t Address, int OpNum,
65
            SStream *O);
66
static void printPCRelTLSOperand(MCInst *MI, uint64_t Address, int OpNum,
67
         SStream *O);
68
// This forms part of the instruction name rather than the operand list.
69
// Print the mnemonic for a condition-code mask ("ne", "lh", etc.)
70
static void printCond4Operand(MCInst *MI, int OpNum, SStream *O);
71
72
#include "SystemZGenAsmWriter.inc"
73
74
#define DECLARE_printUImmOperand(N) \
75
  static void CONCAT(printUImmOperand, N)(MCInst * MI, int OpNum, \
76
            SStream *O);
77
DECLARE_printUImmOperand(1);
78
DECLARE_printUImmOperand(2);
79
DECLARE_printUImmOperand(3);
80
DECLARE_printUImmOperand(4);
81
DECLARE_printUImmOperand(8);
82
DECLARE_printUImmOperand(12);
83
DECLARE_printUImmOperand(16);
84
DECLARE_printUImmOperand(32);
85
DECLARE_printUImmOperand(48);
86
87
#define DECLARE_printSImmOperand(N) \
88
  static void CONCAT(printSImmOperand, N)(MCInst * MI, int OpNum, \
89
            SStream *O);
90
DECLARE_printSImmOperand(8);
91
DECLARE_printSImmOperand(16);
92
DECLARE_printSImmOperand(32);
93
94
static void printAddress(const MCAsmInfo *MAI, MCRegister Base,
95
       const MCOperand *DispMO, MCRegister Index, SStream *O)
96
43.9k
{
97
43.9k
  printMCOperandMAI(DispMO, MAI, O);
98
43.9k
  if (Base || Index) {
99
30.6k
    SStream_concat0(O, "(");
100
101
30.6k
    if (Index) {
102
12.7k
      printFormattedRegName(MAI, Index, O);
103
12.7k
      SStream_concat0(O, ",");
104
12.7k
    }
105
30.6k
    if (Base)
106
27.7k
      printFormattedRegName(MAI, Base, O);
107
2.83k
    else
108
2.83k
      SStream_concat0(O, "0");
109
110
30.6k
    SStream_concat0(O, ")");
111
30.6k
  }
112
43.9k
}
113
114
static void printMCOperandMAI(const MCOperand *MO, const MCAsmInfo *MAI,
115
            SStream *O)
116
50.9k
{
117
50.9k
  if (MCOperand_isReg(MO)) {
118
0
    if (!MCOperand_getReg(MO))
119
0
      SStream_concat1(O, '0');
120
0
    else
121
0
      printFormattedRegName(MAI, MCOperand_getReg(MO), O);
122
50.9k
  } else if (MCOperand_isImm(MO))
123
50.9k
    printInt64(markup_OS(O, Markup_Immediate),
124
50.9k
         MCOperand_getImm(MO));
125
0
  else if (MCOperand_isExpr(MO))
126
0
    printExpr(O, MCOperand_getExpr(MO));
127
0
  else
128
0
    CS_ASSERT(0 && "Invalid operand");
129
50.9k
}
130
131
static void printMCOperand(const MCInst *MI, const MCOperand *MO, SStream *O)
132
127k
{
133
127k
  if (MCOperand_isReg(MO)) {
134
127k
    if (!MCOperand_getReg(MO))
135
1.20k
      SStream_concat0(O, "0");
136
137
125k
    else
138
125k
      printFormattedRegName(&MI->MAI, MCOperand_getReg(MO),
139
125k
                O);
140
127k
  } else if (MCOperand_isImm(MO))
141
0
    printInt64(markup_OS(O, Markup_Immediate),
142
0
         MCOperand_getImm(MO));
143
0
  else if (MCOperand_isExpr(MO))
144
0
    printExpr(O, MCOperand_getExpr(MO));
145
0
  else
146
0
    CS_ASSERT_RET(0 && "Invalid operand");
147
127k
}
148
149
void printFormattedRegName(const MCAsmInfo *MAI, MCRegister Reg, SStream *O)
150
172k
{
151
172k
  const char *RegName = getRegisterName(Reg);
152
172k
  if (MAI->assemblerDialect == SYSTEMZASMDIALECT_AD_ATT) {
153
    // Skip register prefix so that only register number is left
154
0
    CS_ASSERT((isalpha(RegName[0]) && isdigit(RegName[1])));
155
0
    SStream_concat0(markup_OS(O, Markup_Register), (RegName + 1));
156
0
  } else
157
172k
    SStream_concat1(markup_OS(O, Markup_Register), '%');
158
172k
  SStream_concat0(markup_OS(O, Markup_Register), RegName);
159
172k
}
160
161
static void printRegName(const MCInst *MI, SStream *O, MCRegister Reg)
162
6.01k
{
163
6.01k
  printFormattedRegName(&MI->MAI, Reg, O);
164
6.01k
}
165
166
static void printInst(MCInst *MI, uint64_t Address, const char *Annot,
167
          SStream *O)
168
89.2k
{
169
89.2k
  printInstruction(MI, Address, O);
170
89.2k
}
171
172
#define DEFINE_printUImmOperand(N) \
173
  void CONCAT(printUImmOperand, N)(MCInst * MI, int OpNum, SStream *O) \
174
28.8k
  { \
175
28.8k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
28.8k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
28.8k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
28.8k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
28.8k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
28.8k
  }
SystemZInstPrinter.c:printUImmOperand_4
Line
Count
Source
174
19.2k
  { \
175
19.2k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
19.2k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
19.2k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
19.2k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
19.2k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
19.2k
  }
SystemZInstPrinter.c:printUImmOperand_16
Line
Count
Source
174
1.66k
  { \
175
1.66k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
1.66k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
1.66k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
1.66k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
1.66k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
1.66k
  }
SystemZInstPrinter.c:printUImmOperand_32
Line
Count
Source
174
709
  { \
175
709
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
709
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
709
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
709
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
709
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
709
  }
Unexecuted instantiation: SystemZInstPrinter.c:printUImmOperand_48
SystemZInstPrinter.c:printUImmOperand_8
Line
Count
Source
174
4.54k
  { \
175
4.54k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
4.54k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
4.54k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
4.54k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
4.54k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
4.54k
  }
SystemZInstPrinter.c:printUImmOperand_2
Line
Count
Source
174
750
  { \
175
750
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
750
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
750
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
750
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
750
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
750
  }
SystemZInstPrinter.c:printUImmOperand_1
Line
Count
Source
174
831
  { \
175
831
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
831
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
831
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
831
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
831
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
831
  }
SystemZInstPrinter.c:printUImmOperand_12
Line
Count
Source
174
431
  { \
175
431
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
431
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
431
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
431
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
431
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
431
  }
SystemZInstPrinter.c:printUImmOperand_3
Line
Count
Source
174
625
  { \
175
625
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
625
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
625
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
625
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
625
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
625
  }
184
DEFINE_printUImmOperand(1);
185
DEFINE_printUImmOperand(2);
186
DEFINE_printUImmOperand(3);
187
DEFINE_printUImmOperand(4);
188
DEFINE_printUImmOperand(8);
189
DEFINE_printUImmOperand(12);
190
DEFINE_printUImmOperand(16);
191
DEFINE_printUImmOperand(32);
192
DEFINE_printUImmOperand(48);
193
194
#define DEFINE_printSImmOperand(N) \
195
  void CONCAT(printSImmOperand, N)(MCInst * MI, int OpNum, SStream *O) \
196
3.28k
  { \
197
3.28k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
3.28k
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
3.28k
    int64_t Value = \
203
3.28k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
3.28k
    if (N == 8) \
205
3.28k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
3.28k
    else if (N == 16) \
207
2.15k
      printInt16(markup_OS(O, Markup_Immediate), Value); \
208
2.15k
    else if (N == 32) \
209
473
      printInt32(markup_OS(O, Markup_Immediate), Value); \
210
473
    else \
211
473
      CS_ASSERT(0 && "Unreachable"); \
212
3.28k
  }
SystemZInstPrinter.c:printSImmOperand_8
Line
Count
Source
196
1.12k
  { \
197
1.12k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
1.12k
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
1.12k
    int64_t Value = \
203
1.12k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
1.12k
    if (N == 8) \
205
1.12k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
1.12k
    else if (N == 16) \
207
0
      printInt16(markup_OS(O, Markup_Immediate), Value); \
208
0
    else if (N == 32) \
209
0
      printInt32(markup_OS(O, Markup_Immediate), Value); \
210
0
    else \
211
0
      CS_ASSERT(0 && "Unreachable"); \
212
1.12k
  }
SystemZInstPrinter.c:printSImmOperand_16
Line
Count
Source
196
1.68k
  { \
197
1.68k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
1.68k
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
1.68k
    int64_t Value = \
203
1.68k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
1.68k
    if (N == 8) \
205
1.68k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
1.68k
    else if (N == 16) \
207
1.68k
      printInt16(markup_OS(O, Markup_Immediate), Value); \
208
1.68k
    else if (N == 32) \
209
0
      printInt32(markup_OS(O, Markup_Immediate), Value); \
210
0
    else \
211
0
      CS_ASSERT(0 && "Unreachable"); \
212
1.68k
  }
SystemZInstPrinter.c:printSImmOperand_32
Line
Count
Source
196
473
  { \
197
473
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
473
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
473
    int64_t Value = \
203
473
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
473
    if (N == 8) \
205
473
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
473
    else if (N == 16) \
207
473
      printInt16(markup_OS(O, Markup_Immediate), Value); \
208
473
    else if (N == 32) \
209
473
      printInt32(markup_OS(O, Markup_Immediate), Value); \
210
473
    else \
211
473
      CS_ASSERT(0 && "Unreachable"); \
212
473
  }
213
DEFINE_printSImmOperand(8);
214
DEFINE_printSImmOperand(16);
215
DEFINE_printSImmOperand(32);
216
217
static void printU1ImmOperand(MCInst *MI, int OpNum, SStream *O)
218
831
{
219
831
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U1ImmOperand, OpNum);
220
831
  CONCAT(printUImmOperand, 1)(MI, OpNum, O);
221
831
}
222
223
static void printU2ImmOperand(MCInst *MI, int OpNum, SStream *O)
224
750
{
225
750
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U2ImmOperand, OpNum);
226
750
  CONCAT(printUImmOperand, 2)(MI, OpNum, O);
227
750
}
228
229
static void printU3ImmOperand(MCInst *MI, int OpNum, SStream *O)
230
625
{
231
625
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U3ImmOperand, OpNum);
232
625
  CONCAT(printUImmOperand, 3)(MI, OpNum, O);
233
625
}
234
235
static void printU4ImmOperand(MCInst *MI, int OpNum, SStream *O)
236
19.2k
{
237
19.2k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U4ImmOperand, OpNum);
238
19.2k
  CONCAT(printUImmOperand, 4)(MI, OpNum, O);
239
19.2k
}
240
241
static void printS8ImmOperand(MCInst *MI, int OpNum, SStream *O)
242
1.12k
{
243
1.12k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_S8ImmOperand, OpNum);
244
1.12k
  CONCAT(printSImmOperand, 8)(MI, OpNum, O);
245
1.12k
}
246
247
static void printU8ImmOperand(MCInst *MI, int OpNum, SStream *O)
248
4.54k
{
249
4.54k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U8ImmOperand, OpNum);
250
4.54k
  CONCAT(printUImmOperand, 8)(MI, OpNum, O);
251
4.54k
}
252
253
static void printU12ImmOperand(MCInst *MI, int OpNum, SStream *O)
254
431
{
255
431
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U12ImmOperand, OpNum);
256
431
  CONCAT(printUImmOperand, 12)(MI, OpNum, O);
257
431
}
258
259
static void printS16ImmOperand(MCInst *MI, int OpNum, SStream *O)
260
1.68k
{
261
1.68k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_S16ImmOperand, OpNum);
262
1.68k
  CONCAT(printSImmOperand, 16)(MI, OpNum, O);
263
1.68k
}
264
265
static void printU16ImmOperand(MCInst *MI, int OpNum, SStream *O)
266
1.66k
{
267
1.66k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U16ImmOperand, OpNum);
268
1.66k
  CONCAT(printUImmOperand, 16)(MI, OpNum, O);
269
1.66k
}
270
271
static void printS32ImmOperand(MCInst *MI, int OpNum, SStream *O)
272
473
{
273
473
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_S32ImmOperand, OpNum);
274
473
  CONCAT(printSImmOperand, 32)(MI, OpNum, O);
275
473
}
276
277
static void printU32ImmOperand(MCInst *MI, int OpNum, SStream *O)
278
709
{
279
709
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U32ImmOperand, OpNum);
280
709
  CONCAT(printUImmOperand, 32)(MI, OpNum, O);
281
709
}
282
283
static void printU48ImmOperand(MCInst *MI, int OpNum, SStream *O)
284
0
{
285
0
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U48ImmOperand, OpNum);
286
0
  CONCAT(printUImmOperand, 48)(MI, OpNum, O);
287
0
}
288
289
static void printPCRelOperand(MCInst *MI, uint64_t Address, int OpNum,
290
            SStream *O)
291
4.34k
{
292
4.34k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_PCRelOperand, OpNum);
293
4.34k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
294
4.34k
  if (MCOperand_isImm(MO)) {
295
4.34k
    printInt64(O, MCOperand_getImm(MO));
296
4.34k
  } else
297
0
    printExpr(O, MCOperand_getExpr(MO));
298
4.34k
}
299
300
static void printPCRelTLSOperand(MCInst *MI, uint64_t Address, int OpNum,
301
         SStream *O)
302
262
{
303
  // Output the PC-relative operand.
304
262
  printPCRelOperand(MI, MI->address, OpNum, O);
305
306
  // Output the TLS marker if present.
307
262
  if ((unsigned)OpNum + 1 < MCInst_getNumOperands(MI)) {
308
    // Expressions not supported
309
0
  }
310
262
}
311
312
static void printOperand(MCInst *MI, int OpNum, SStream *O)
313
235k
{
314
235k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_Operand, OpNum);
315
235k
  printMCOperand(MI, MCInst_getOperand(MI, (OpNum)), O);
316
235k
}
317
318
static void printBDAddrOperand(MCInst *MI, int OpNum, SStream *O)
319
40.5k
{
320
40.5k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDAddrOperand, OpNum);
321
40.5k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
322
40.5k
         MCInst_getOperand(MI, (OpNum + 1)), 0, O);
323
40.5k
}
324
325
static void printBDXAddrOperand(MCInst *MI, int OpNum, SStream *O)
326
30.6k
{
327
30.6k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDXAddrOperand, OpNum);
328
30.6k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
329
30.6k
         MCInst_getOperand(MI, (OpNum + 1)),
330
30.6k
         MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2))), O);
331
30.6k
}
332
333
static void printBDLAddrOperand(MCInst *MI, int OpNum, SStream *O)
334
6.49k
{
335
6.49k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDLAddrOperand, OpNum);
336
6.49k
  unsigned Base = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
337
6.49k
  MCOperand *DispMO = MCInst_getOperand(MI, (OpNum + 1));
338
6.49k
  uint64_t Length = MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 2)));
339
6.49k
  printMCOperandMAI(DispMO, &MI->MAI, O);
340
6.49k
  SStream_concat1(O, '(');
341
6.49k
  printUInt64(O, Length);
342
6.49k
  if (Base) {
343
5.15k
    SStream_concat0(O, ",");
344
5.15k
    printRegName(MI, O, Base);
345
5.15k
  }
346
6.49k
  SStream_concat0(O, ")");
347
6.49k
}
348
349
static void printBDRAddrOperand(MCInst *MI, int OpNum, SStream *O)
350
459
{
351
459
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDRAddrOperand, OpNum);
352
459
  unsigned Base = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
353
459
  MCOperand *DispMO = MCInst_getOperand(MI, (OpNum + 1));
354
459
  unsigned Length = MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2)));
355
459
  printMCOperandMAI(DispMO, &MI->MAI, O);
356
459
  SStream_concat0(O, "(");
357
459
  printRegName(MI, O, Length);
358
459
  if (Base) {
359
399
    SStream_concat0(O, ",");
360
399
    printRegName(MI, O, Base);
361
399
  }
362
459
  SStream_concat0(O, ")");
363
459
}
364
365
static void printBDVAddrOperand(MCInst *MI, int OpNum, SStream *O)
366
1.45k
{
367
1.45k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDVAddrOperand, OpNum);
368
1.45k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
369
1.45k
         MCInst_getOperand(MI, (OpNum + 1)),
370
1.45k
         MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2))), O);
371
1.45k
}
372
373
static void printCond4Operand(MCInst *MI, int OpNum, SStream *O)
374
0
{
375
0
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_Cond4Operand, OpNum);
376
0
  static const char *const CondNames[] = { "o", "h",  "nle", "l",
377
0
             "nhe", "lh", "ne",  "e",
378
0
             "nlh", "he", "nl",  "le",
379
0
             "nh",  "no" };
380
0
  uint64_t Imm = MCOperand_getImm(MCInst_getOperand(MI, (OpNum)));
381
0
  CS_ASSERT((Imm > 0 && Imm < 15 && "Invalid condition"));
382
0
  SStream_concat0(O, CondNames[Imm - 1]);
383
0
}
384
385
const char *SystemZ_LLVM_getRegisterName(unsigned RegNo)
386
53.5k
{
387
53.5k
  return getRegisterName(RegNo);
388
53.5k
}
389
390
void SystemZ_LLVM_printInstruction(MCInst *MI, const char *Annotation,
391
           SStream *O)
392
89.2k
{
393
89.2k
  printInst(MI, MI->address, Annotation, O);
394
89.2k
}