Coverage Report

Created: 2025-07-11 06:32

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