Coverage Report

Created: 2025-07-04 06:11

/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
33.8k
#define CONCAT(a, b) CONCAT_(a, b)
37
33.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
55.6k
{
92
55.6k
  printMCOperandMAI(DispMO, MAI, O);
93
55.6k
  if (Base || Index) {
94
42.8k
    SStream_concat0(O, "(");
95
96
42.8k
    if (Index) {
97
20.0k
      printFormattedRegName(MAI, Index, O);
98
20.0k
      SStream_concat0(O, ",");
99
20.0k
    }
100
42.8k
    if (Base)
101
36.4k
      printFormattedRegName(MAI, Base, O);
102
6.35k
    else
103
6.35k
      SStream_concat0(O, "0");
104
105
42.8k
    SStream_concat0(O, ")");
106
42.8k
  }
107
55.6k
}
108
109
static void printMCOperandMAI(const MCOperand *MO, const MCAsmInfo *MAI,
110
64.5k
                                      SStream *O) {
111
64.5k
  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
64.5k
  else if (MCOperand_isImm(MO))
118
64.5k
    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
64.5k
}
124
125
static void printMCOperand(const MCInst *MI, const MCOperand *MO, SStream *O)
126
150k
{
127
150k
  if (MCOperand_isReg(MO)) {
128
150k
    if (!MCOperand_getReg(MO))
129
1.21k
      SStream_concat0(O, "0");
130
131
149k
    else
132
149k
      printFormattedRegName(&MI->MAI, MCOperand_getReg(MO), O);
133
150k
  } 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
150k
}
141
142
void printFormattedRegName(const MCAsmInfo *MAI, MCRegister Reg, SStream *O)
143
213k
{
144
213k
  const char *RegName = getRegisterName(Reg);
145
213k
  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
213k
    SStream_concat1(markup_OS(O, Markup_Register), '%');
151
213k
  SStream_concat0(markup_OS(O, Markup_Register), RegName);
152
213k
}
153
154
static void printRegName(const MCInst *MI, SStream *O, MCRegister Reg)
155
7.56k
{
156
7.56k
  printFormattedRegName(&MI->MAI, Reg, O);
157
7.56k
}
158
159
static void printInst(MCInst *MI, uint64_t Address, const char *Annot, SStream *O)
160
108k
{
161
108k
  printInstruction(MI, Address, O);
162
108k
}
163
164
#define DEFINE_printUImmOperand(N) \
165
  void CONCAT(printUImmOperand, N)(MCInst * MI, int OpNum, SStream *O) \
166
30.0k
  { \
167
30.0k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
30.0k
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
30.0k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
30.0k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
30.0k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
30.0k
  }
SystemZInstPrinter.c:printUImmOperand_4
Line
Count
Source
166
19.2k
  { \
167
19.2k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
19.2k
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
19.2k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
19.2k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
19.2k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
19.2k
  }
SystemZInstPrinter.c:printUImmOperand_16
Line
Count
Source
166
1.53k
  { \
167
1.53k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
1.53k
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
1.53k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
1.53k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
1.53k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
1.53k
  }
SystemZInstPrinter.c:printUImmOperand_32
Line
Count
Source
166
883
  { \
167
883
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
883
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
883
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
883
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
883
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
883
  }
Unexecuted instantiation: SystemZInstPrinter.c:printUImmOperand_48
SystemZInstPrinter.c:printUImmOperand_8
Line
Count
Source
166
5.19k
  { \
167
5.19k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
5.19k
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
5.19k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
5.19k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
5.19k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
5.19k
  }
SystemZInstPrinter.c:printUImmOperand_2
Line
Count
Source
166
1.40k
  { \
167
1.40k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
1.40k
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
1.40k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
1.40k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
1.40k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
1.40k
  }
SystemZInstPrinter.c:printUImmOperand_1
Line
Count
Source
166
932
  { \
167
932
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
932
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
932
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
932
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
932
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
932
  }
SystemZInstPrinter.c:printUImmOperand_12
Line
Count
Source
166
70
  { \
167
70
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
70
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
70
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
70
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
70
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
70
  }
SystemZInstPrinter.c:printUImmOperand_3
Line
Count
Source
166
755
  { \
167
755
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
168
755
    if (MCOperand_isExpr(MO)) { \
169
0
      printExpr(O, MCOperand_getExpr(MO)); \
170
0
      return; \
171
0
    } \
172
755
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
173
755
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
174
755
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
175
755
  }
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
3.84k
  { \
189
3.84k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
190
3.84k
    if (MCOperand_isExpr(MO)) { \
191
0
      printExpr(O, MCOperand_getExpr(MO)); \
192
0
      return; \
193
0
    } \
194
3.84k
    int64_t Value = \
195
3.84k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
196
3.84k
    if (N == 8) \
197
3.84k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
198
3.84k
    else if (N == 16) \
199
2.86k
      printInt16(markup_OS(O, Markup_Immediate), Value); \
200
2.86k
    else if (N == 32) \
201
619
      printInt32(markup_OS(O, Markup_Immediate), Value); \
202
619
    else \
203
619
      CS_ASSERT(0 && "Unreachable"); \
204
3.84k
  }
SystemZInstPrinter.c:printSImmOperand_8
Line
Count
Source
188
981
  { \
189
981
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
190
981
    if (MCOperand_isExpr(MO)) { \
191
0
      printExpr(O, MCOperand_getExpr(MO)); \
192
0
      return; \
193
0
    } \
194
981
    int64_t Value = \
195
981
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
196
981
    if (N == 8) \
197
981
      printInt8(markup_OS(O, Markup_Immediate), Value); \
198
981
    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
981
  }
SystemZInstPrinter.c:printSImmOperand_16
Line
Count
Source
188
2.24k
  { \
189
2.24k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
190
2.24k
    if (MCOperand_isExpr(MO)) { \
191
0
      printExpr(O, MCOperand_getExpr(MO)); \
192
0
      return; \
193
0
    } \
194
2.24k
    int64_t Value = \
195
2.24k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
196
2.24k
    if (N == 8) \
197
2.24k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
198
2.24k
    else if (N == 16) \
199
2.24k
      printInt16(markup_OS(O, Markup_Immediate), Value); \
200
2.24k
    else if (N == 32) \
201
0
      printInt32(markup_OS(O, Markup_Immediate), Value); \
202
0
    else \
203
0
      CS_ASSERT(0 && "Unreachable"); \
204
2.24k
  }
SystemZInstPrinter.c:printSImmOperand_32
Line
Count
Source
188
619
  { \
189
619
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
190
619
    if (MCOperand_isExpr(MO)) { \
191
0
      printExpr(O, MCOperand_getExpr(MO)); \
192
0
      return; \
193
0
    } \
194
619
    int64_t Value = \
195
619
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
196
619
    if (N == 8) \
197
619
      printInt8(markup_OS(O, Markup_Immediate), Value); \
198
619
    else if (N == 16) \
199
619
      printInt16(markup_OS(O, Markup_Immediate), Value); \
200
619
    else if (N == 32) \
201
619
      printInt32(markup_OS(O, Markup_Immediate), Value); \
202
619
    else \
203
619
      CS_ASSERT(0 && "Unreachable"); \
204
619
  }
205
DEFINE_printSImmOperand(8);
206
DEFINE_printSImmOperand(16);
207
DEFINE_printSImmOperand(32);
208
209
static void printU1ImmOperand(MCInst *MI, int OpNum, SStream *O)
210
932
{
211
932
  add_cs_detail(MI, SystemZ_OP_GROUP_U1ImmOperand, OpNum);
212
932
  CONCAT(printUImmOperand, 1)(MI, OpNum, O);
213
932
}
214
215
static void printU2ImmOperand(MCInst *MI, int OpNum, SStream *O)
216
1.40k
{
217
1.40k
  add_cs_detail(MI, SystemZ_OP_GROUP_U2ImmOperand, OpNum);
218
1.40k
  CONCAT(printUImmOperand, 2)(MI, OpNum, O);
219
1.40k
}
220
221
static void printU3ImmOperand(MCInst *MI, int OpNum, SStream *O)
222
755
{
223
755
  add_cs_detail(MI, SystemZ_OP_GROUP_U3ImmOperand, OpNum);
224
755
  CONCAT(printUImmOperand, 3)(MI, OpNum, O);
225
755
}
226
227
static void printU4ImmOperand(MCInst *MI, int OpNum, SStream *O)
228
19.2k
{
229
19.2k
  add_cs_detail(MI, SystemZ_OP_GROUP_U4ImmOperand, OpNum);
230
19.2k
  CONCAT(printUImmOperand, 4)(MI, OpNum, O);
231
19.2k
}
232
233
static void printS8ImmOperand(MCInst *MI, int OpNum, SStream *O)
234
981
{
235
981
  add_cs_detail(MI, SystemZ_OP_GROUP_S8ImmOperand, OpNum);
236
981
  CONCAT(printSImmOperand, 8)(MI, OpNum, O);
237
981
}
238
239
static void printU8ImmOperand(MCInst *MI, int OpNum, SStream *O)
240
5.19k
{
241
5.19k
  add_cs_detail(MI, SystemZ_OP_GROUP_U8ImmOperand, OpNum);
242
5.19k
  CONCAT(printUImmOperand, 8)(MI, OpNum, O);
243
5.19k
}
244
245
static void printU12ImmOperand(MCInst *MI, int OpNum, SStream *O)
246
70
{
247
70
  add_cs_detail(MI, SystemZ_OP_GROUP_U12ImmOperand, OpNum);
248
70
  CONCAT(printUImmOperand, 12)(MI, OpNum, O);
249
70
}
250
251
static void printS16ImmOperand(MCInst *MI, int OpNum, SStream *O)
252
2.24k
{
253
2.24k
  add_cs_detail(MI, SystemZ_OP_GROUP_S16ImmOperand, OpNum);
254
2.24k
  CONCAT(printSImmOperand, 16)(MI, OpNum, O);
255
2.24k
}
256
257
static void printU16ImmOperand(MCInst *MI, int OpNum, SStream *O)
258
1.53k
{
259
1.53k
  add_cs_detail(MI, SystemZ_OP_GROUP_U16ImmOperand, OpNum);
260
1.53k
  CONCAT(printUImmOperand, 16)(MI, OpNum, O);
261
1.53k
}
262
263
static void printS32ImmOperand(MCInst *MI, int OpNum, SStream *O)
264
619
{
265
619
  add_cs_detail(MI, SystemZ_OP_GROUP_S32ImmOperand, OpNum);
266
619
  CONCAT(printSImmOperand, 32)(MI, OpNum, O);
267
619
}
268
269
static void printU32ImmOperand(MCInst *MI, int OpNum, SStream *O)
270
883
{
271
883
  add_cs_detail(MI, SystemZ_OP_GROUP_U32ImmOperand, OpNum);
272
883
  CONCAT(printUImmOperand, 32)(MI, OpNum, O);
273
883
}
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
4.15k
{
283
4.15k
  add_cs_detail(MI, SystemZ_OP_GROUP_PCRelOperand, OpNum);
284
4.15k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
285
4.15k
  if (MCOperand_isImm(MO)) {
286
4.15k
    printInt64(O, MCOperand_getImm(MO));
287
4.15k
  } else
288
0
    printExpr(O, MCOperand_getExpr(MO));
289
4.15k
}
290
291
static void printPCRelTLSOperand(MCInst *MI, uint64_t Address, int OpNum, SStream *O)
292
264
{
293
  // Output the PC-relative operand.
294
264
  printPCRelOperand(MI, MI->address, OpNum, O);
295
296
  // Output the TLS marker if present.
297
264
  if ((unsigned)OpNum + 1 < MCInst_getNumOperands(MI)) {
298
    // Expressions not supported
299
0
  }
300
264
}
301
302
static void printOperand(MCInst *MI, int OpNum, SStream *O)
303
272k
{
304
272k
  add_cs_detail(MI, SystemZ_OP_GROUP_Operand, OpNum);
305
272k
  printMCOperand(MI, MCInst_getOperand(MI, (OpNum)), O);
306
272k
}
307
308
static void printBDAddrOperand(MCInst *MI, int OpNum, SStream *O)
309
47.4k
{
310
47.4k
  add_cs_detail(MI, SystemZ_OP_GROUP_BDAddrOperand, OpNum);
311
47.4k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
312
47.4k
         MCInst_getOperand(MI, (OpNum + 1)), 0, O);
313
47.4k
}
314
315
static void printBDXAddrOperand(MCInst *MI, int OpNum, SStream *O)
316
42.3k
{
317
42.3k
  add_cs_detail(MI, SystemZ_OP_GROUP_BDXAddrOperand, OpNum);
318
42.3k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
319
42.3k
         MCInst_getOperand(MI, (OpNum + 1)),
320
42.3k
         MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2))), O);
321
42.3k
}
322
323
static void printBDLAddrOperand(MCInst *MI, int OpNum, SStream *O)
324
8.19k
{
325
8.19k
  add_cs_detail(MI, SystemZ_OP_GROUP_BDLAddrOperand, OpNum);
326
8.19k
  unsigned Base = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
327
8.19k
  MCOperand *DispMO = MCInst_getOperand(MI, (OpNum + 1));
328
8.19k
  uint64_t Length = MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 2)));
329
8.19k
  printMCOperandMAI(DispMO, &MI->MAI, O);
330
8.19k
  SStream_concat1(O, '(');
331
8.19k
  printUInt64(O, Length);
332
8.19k
  if (Base) {
333
6.30k
    SStream_concat0(O, ",");
334
6.30k
    printRegName(MI, O, Base);
335
6.30k
  }
336
8.19k
  SStream_concat0(O, ")");
337
8.19k
}
338
339
static void printBDRAddrOperand(MCInst *MI, int OpNum, SStream *O)
340
677
{
341
677
  add_cs_detail(MI, SystemZ_OP_GROUP_BDRAddrOperand, OpNum);
342
677
  unsigned Base = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
343
677
  MCOperand *DispMO = MCInst_getOperand(MI, (OpNum + 1));
344
677
  unsigned Length = MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2)));
345
677
  printMCOperandMAI(DispMO, &MI->MAI, O);
346
677
  SStream_concat0(O, "(");
347
677
  printRegName(MI, O, Length);
348
677
  if (Base) {
349
585
    SStream_concat0(O, ",");
350
585
    printRegName(MI, O, Base);
351
585
  }
352
677
  SStream_concat0(O, ")");
353
677
}
354
355
static void printBDVAddrOperand(MCInst *MI, int OpNum, SStream *O)
356
1.42k
{
357
1.42k
  add_cs_detail(MI, SystemZ_OP_GROUP_BDVAddrOperand, OpNum);
358
1.42k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
359
1.42k
         MCInst_getOperand(MI, (OpNum + 1)),
360
1.42k
         MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2))), O);
361
1.42k
}
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
70.2k
{
377
70.2k
  return getRegisterName(RegNo);
378
70.2k
}
379
380
void SystemZ_LLVM_printInstruction(MCInst *MI, const char *Annotation, SStream *O)
381
108k
{
382
108k
  printInst(MI, MI->address, Annotation, O);
383
108k
}