Coverage Report

Created: 2026-07-16 06:55

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
51.9k
#define CONCAT(a, b) CONCAT_(a, b)
37
51.9k
#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
77.9k
{
97
77.9k
  printMCOperandMAI(DispMO, MAI, O);
98
77.9k
  if (Base || Index) {
99
57.6k
    SStream_concat0(O, "(");
100
101
57.6k
    if (Index) {
102
28.1k
      printFormattedRegName(MAI, Index, O);
103
28.1k
      SStream_concat0(O, ",");
104
28.1k
    }
105
57.6k
    if (Base)
106
50.4k
      printFormattedRegName(MAI, Base, O);
107
7.12k
    else
108
7.12k
      SStream_concat0(O, "0");
109
110
57.6k
    SStream_concat0(O, ")");
111
57.6k
  }
112
77.9k
}
113
114
static void printMCOperandMAI(const MCOperand *MO, const MCAsmInfo *MAI,
115
            SStream *O)
116
92.8k
{
117
92.8k
  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
92.8k
  } else if (MCOperand_isImm(MO))
123
92.8k
    printInt64(markup_OS(O, Markup_Immediate),
124
92.8k
         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
92.8k
}
130
131
static void printMCOperand(const MCInst *MI, const MCOperand *MO, SStream *O)
132
208k
{
133
208k
  if (MCOperand_isReg(MO)) {
134
208k
    if (!MCOperand_getReg(MO))
135
838
      SStream_concat0(O, "0");
136
137
207k
    else
138
207k
      printFormattedRegName(&MI->MAI, MCOperand_getReg(MO),
139
207k
                O);
140
208k
  } 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
208k
}
148
149
void printFormattedRegName(const MCAsmInfo *MAI, MCRegister Reg, SStream *O)
150
298k
{
151
298k
  const char *RegName = getRegisterName(Reg);
152
298k
  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
298k
    SStream_concat1(markup_OS(O, Markup_Register), '%');
158
298k
  SStream_concat0(markup_OS(O, Markup_Register), RegName);
159
298k
}
160
161
static void printRegName(const MCInst *MI, SStream *O, MCRegister Reg)
162
12.7k
{
163
12.7k
  printFormattedRegName(&MI->MAI, Reg, O);
164
12.7k
}
165
166
static void printInst(MCInst *MI, uint64_t Address, const char *Annot,
167
          SStream *O)
168
152k
{
169
152k
  printInstruction(MI, Address, O);
170
152k
}
171
172
#define DEFINE_printUImmOperand(N) \
173
  void CONCAT(printUImmOperand, N)(MCInst * MI, int OpNum, SStream *O) \
174
45.7k
  { \
175
45.7k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
45.7k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
45.7k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
45.7k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
45.7k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
45.7k
  }
SystemZInstPrinter.c:printUImmOperand_4
Line
Count
Source
174
29.8k
  { \
175
29.8k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
29.8k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
29.8k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
29.8k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
29.8k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
29.8k
  }
SystemZInstPrinter.c:printUImmOperand_16
Line
Count
Source
174
1.94k
  { \
175
1.94k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
1.94k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
1.94k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
1.94k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
1.94k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
1.94k
  }
SystemZInstPrinter.c:printUImmOperand_32
Line
Count
Source
174
1.89k
  { \
175
1.89k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
1.89k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
1.89k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
1.89k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
1.89k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
1.89k
  }
Unexecuted instantiation: SystemZInstPrinter.c:printUImmOperand_48
SystemZInstPrinter.c:printUImmOperand_8
Line
Count
Source
174
7.96k
  { \
175
7.96k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
7.96k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
7.96k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
7.96k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
7.96k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
7.96k
  }
SystemZInstPrinter.c:printUImmOperand_2
Line
Count
Source
174
1.16k
  { \
175
1.16k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
1.16k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
1.16k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
1.16k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
1.16k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
1.16k
  }
SystemZInstPrinter.c:printUImmOperand_1
Line
Count
Source
174
1.71k
  { \
175
1.71k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
1.71k
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
1.71k
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
1.71k
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
1.71k
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
1.71k
  }
SystemZInstPrinter.c:printUImmOperand_12
Line
Count
Source
174
681
  { \
175
681
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
681
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
681
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
681
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
681
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
681
  }
SystemZInstPrinter.c:printUImmOperand_3
Line
Count
Source
174
529
  { \
175
529
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
176
529
    if (MCOperand_isExpr(MO)) { \
177
0
      printExpr(O, MCOperand_getExpr(MO)); \
178
0
      return; \
179
0
    } \
180
529
    uint64_t Value = (uint64_t)(MCOperand_getImm(MO)); \
181
529
    CS_ASSERT((isUIntN(N, Value) && "Invalid uimm argument")); \
182
529
    printUInt64(markup_OS(O, Markup_Immediate), Value); \
183
529
  }
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
6.24k
  { \
197
6.24k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
6.24k
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
6.24k
    int64_t Value = \
203
6.24k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
6.24k
    if (N == 8) \
205
6.24k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
6.24k
    else if (N == 16) \
207
3.68k
      printInt16(markup_OS(O, Markup_Immediate), Value); \
208
3.68k
    else if (N == 32) \
209
938
      printInt32(markup_OS(O, Markup_Immediate), Value); \
210
938
    else \
211
938
      CS_ASSERT(0 && "Unreachable"); \
212
6.24k
  }
SystemZInstPrinter.c:printSImmOperand_8
Line
Count
Source
196
2.56k
  { \
197
2.56k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
2.56k
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
2.56k
    int64_t Value = \
203
2.56k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
2.56k
    if (N == 8) \
205
2.56k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
2.56k
    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
2.56k
  }
SystemZInstPrinter.c:printSImmOperand_16
Line
Count
Source
196
2.74k
  { \
197
2.74k
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
2.74k
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
2.74k
    int64_t Value = \
203
2.74k
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
2.74k
    if (N == 8) \
205
2.74k
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
2.74k
    else if (N == 16) \
207
2.74k
      printInt16(markup_OS(O, Markup_Immediate), Value); \
208
2.74k
    else if (N == 32) \
209
0
      printInt32(markup_OS(O, Markup_Immediate), Value); \
210
0
    else \
211
0
      CS_ASSERT(0 && "Unreachable"); \
212
2.74k
  }
SystemZInstPrinter.c:printSImmOperand_32
Line
Count
Source
196
938
  { \
197
938
    MCOperand *MO = MCInst_getOperand(MI, (OpNum)); \
198
938
    if (MCOperand_isExpr(MO)) { \
199
0
      printExpr(O, MCOperand_getExpr(MO)); \
200
0
      return; \
201
0
    } \
202
938
    int64_t Value = \
203
938
      MCOperand_getImm(MCInst_getOperand(MI, (OpNum))); \
204
938
    if (N == 8) \
205
938
      printInt8(markup_OS(O, Markup_Immediate), Value); \
206
938
    else if (N == 16) \
207
938
      printInt16(markup_OS(O, Markup_Immediate), Value); \
208
938
    else if (N == 32) \
209
938
      printInt32(markup_OS(O, Markup_Immediate), Value); \
210
938
    else \
211
938
      CS_ASSERT(0 && "Unreachable"); \
212
938
  }
213
DEFINE_printSImmOperand(8);
214
DEFINE_printSImmOperand(16);
215
DEFINE_printSImmOperand(32);
216
217
static void printU1ImmOperand(MCInst *MI, int OpNum, SStream *O)
218
1.71k
{
219
1.71k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U1ImmOperand, OpNum);
220
1.71k
  CONCAT(printUImmOperand, 1)(MI, OpNum, O);
221
1.71k
}
222
223
static void printU2ImmOperand(MCInst *MI, int OpNum, SStream *O)
224
1.16k
{
225
1.16k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U2ImmOperand, OpNum);
226
1.16k
  CONCAT(printUImmOperand, 2)(MI, OpNum, O);
227
1.16k
}
228
229
static void printU3ImmOperand(MCInst *MI, int OpNum, SStream *O)
230
529
{
231
529
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U3ImmOperand, OpNum);
232
529
  CONCAT(printUImmOperand, 3)(MI, OpNum, O);
233
529
}
234
235
static void printU4ImmOperand(MCInst *MI, int OpNum, SStream *O)
236
29.8k
{
237
29.8k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U4ImmOperand, OpNum);
238
29.8k
  CONCAT(printUImmOperand, 4)(MI, OpNum, O);
239
29.8k
}
240
241
static void printS8ImmOperand(MCInst *MI, int OpNum, SStream *O)
242
2.56k
{
243
2.56k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_S8ImmOperand, OpNum);
244
2.56k
  CONCAT(printSImmOperand, 8)(MI, OpNum, O);
245
2.56k
}
246
247
static void printU8ImmOperand(MCInst *MI, int OpNum, SStream *O)
248
7.96k
{
249
7.96k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U8ImmOperand, OpNum);
250
7.96k
  CONCAT(printUImmOperand, 8)(MI, OpNum, O);
251
7.96k
}
252
253
static void printU12ImmOperand(MCInst *MI, int OpNum, SStream *O)
254
681
{
255
681
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U12ImmOperand, OpNum);
256
681
  CONCAT(printUImmOperand, 12)(MI, OpNum, O);
257
681
}
258
259
static void printS16ImmOperand(MCInst *MI, int OpNum, SStream *O)
260
2.74k
{
261
2.74k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_S16ImmOperand, OpNum);
262
2.74k
  CONCAT(printSImmOperand, 16)(MI, OpNum, O);
263
2.74k
}
264
265
static void printU16ImmOperand(MCInst *MI, int OpNum, SStream *O)
266
1.94k
{
267
1.94k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U16ImmOperand, OpNum);
268
1.94k
  CONCAT(printUImmOperand, 16)(MI, OpNum, O);
269
1.94k
}
270
271
static void printS32ImmOperand(MCInst *MI, int OpNum, SStream *O)
272
938
{
273
938
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_S32ImmOperand, OpNum);
274
938
  CONCAT(printSImmOperand, 32)(MI, OpNum, O);
275
938
}
276
277
static void printU32ImmOperand(MCInst *MI, int OpNum, SStream *O)
278
1.89k
{
279
1.89k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_U32ImmOperand, OpNum);
280
1.89k
  CONCAT(printUImmOperand, 32)(MI, OpNum, O);
281
1.89k
}
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
6.33k
{
292
6.33k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_PCRelOperand, OpNum);
293
6.33k
  MCOperand *MO = MCInst_getOperand(MI, (OpNum));
294
6.33k
  if (MCOperand_isImm(MO)) {
295
6.33k
    printInt64(O, MCOperand_getImm(MO));
296
6.33k
  } else
297
0
    printExpr(O, MCOperand_getExpr(MO));
298
6.33k
}
299
300
static void printPCRelTLSOperand(MCInst *MI, uint64_t Address, int OpNum,
301
         SStream *O)
302
316
{
303
  // Output the PC-relative operand.
304
316
  printPCRelOperand(MI, MI->address, OpNum, O);
305
306
  // Output the TLS marker if present.
307
316
  if ((unsigned)OpNum + 1 < MCInst_getNumOperands(MI)) {
308
    // Expressions not supported
309
0
  }
310
316
}
311
312
static void printOperand(MCInst *MI, int OpNum, SStream *O)
313
208k
{
314
208k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_Operand, OpNum);
315
208k
  printMCOperand(MI, MCInst_getOperand(MI, (OpNum)), O);
316
208k
}
317
318
static void printBDAddrOperand(MCInst *MI, int OpNum, SStream *O)
319
38.4k
{
320
38.4k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDAddrOperand, OpNum);
321
38.4k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
322
38.4k
         MCInst_getOperand(MI, (OpNum + 1)), 0, O);
323
38.4k
}
324
325
static void printBDXAddrOperand(MCInst *MI, int OpNum, SStream *O)
326
38.8k
{
327
38.8k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDXAddrOperand, OpNum);
328
38.8k
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
329
38.8k
         MCInst_getOperand(MI, (OpNum + 1)),
330
38.8k
         MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2))), O);
331
38.8k
}
332
333
static void printBDLAddrOperand(MCInst *MI, int OpNum, SStream *O)
334
14.3k
{
335
14.3k
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDLAddrOperand, OpNum);
336
14.3k
  unsigned Base = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
337
14.3k
  MCOperand *DispMO = MCInst_getOperand(MI, (OpNum + 1));
338
14.3k
  uint64_t Length = MCOperand_getImm(MCInst_getOperand(MI, (OpNum + 2)));
339
14.3k
  printMCOperandMAI(DispMO, &MI->MAI, O);
340
14.3k
  SStream_concat1(O, '(');
341
14.3k
  printUInt64(O, Length);
342
14.3k
  if (Base) {
343
11.9k
    SStream_concat0(O, ",");
344
11.9k
    printRegName(MI, O, Base);
345
11.9k
  }
346
14.3k
  SStream_concat0(O, ")");
347
14.3k
}
348
349
static void printBDRAddrOperand(MCInst *MI, int OpNum, SStream *O)
350
471
{
351
471
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDRAddrOperand, OpNum);
352
471
  unsigned Base = MCOperand_getReg(MCInst_getOperand(MI, (OpNum)));
353
471
  MCOperand *DispMO = MCInst_getOperand(MI, (OpNum + 1));
354
471
  unsigned Length = MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2)));
355
471
  printMCOperandMAI(DispMO, &MI->MAI, O);
356
471
  SStream_concat0(O, "(");
357
471
  printRegName(MI, O, Length);
358
471
  if (Base) {
359
346
    SStream_concat0(O, ",");
360
346
    printRegName(MI, O, Base);
361
346
  }
362
471
  SStream_concat0(O, ")");
363
471
}
364
365
static void printBDVAddrOperand(MCInst *MI, int OpNum, SStream *O)
366
658
{
367
658
  SystemZ_add_cs_detail_0(MI, SystemZ_OP_GROUP_BDVAddrOperand, OpNum);
368
658
  printAddress(&MI->MAI, MCOperand_getReg(MCInst_getOperand(MI, (OpNum))),
369
658
         MCInst_getOperand(MI, (OpNum + 1)),
370
658
         MCOperand_getReg(MCInst_getOperand(MI, (OpNum + 2))), O);
371
658
}
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
95.5k
{
387
95.5k
  return getRegisterName(RegNo);
388
95.5k
}
389
390
void SystemZ_LLVM_printInstruction(MCInst *MI, const char *Annotation,
391
           SStream *O)
392
152k
{
393
152k
  printInst(MI, MI->address, Annotation, O);
394
152k
}