Coverage Report

Created: 2025-07-18 06:43

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