Coverage Report

Created: 2025-07-01 07:03

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