Coverage Report

Created: 2025-10-14 06:42

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