Coverage Report

Created: 2026-08-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonenext/arch/SystemZ/SystemZDisassembler.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
//===-- SystemZDisassembler.cpp - Disassembler for SystemZ ------*- C++ -*-===//
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 <stdio.h>
24
#include <string.h>
25
#include <stdlib.h>
26
#include <capstone/platform.h>
27
28
#include "../../MCInst.h"
29
#include "../../MathExtras.h"
30
#include "../../MCInstPrinter.h"
31
#include "../../MCDisassembler.h"
32
#include "../../MCFixedLenDisassembler.h"
33
#include "../../cs_priv.h"
34
#include "../../utils.h"
35
36
#include "SystemZMCTargetDesc.h"
37
#include "SystemZDisassemblerExtension.h"
38
39
147k
#define CONCAT(a, b) CONCAT_(a, b)
40
147k
#define CONCAT_(a, b) a##_##b
41
42
#define DEBUG_TYPE "systemz-disassembler"
43
44
static DecodeStatus getInstruction(MCInst *Instr, uint16_t *Size,
45
           const uint8_t *Bytes, size_t BytesLen,
46
           uint64_t Address, SStream *CStream);
47
48
/// tryAddingSymbolicOperand - trys to add a symbolic operand in place of the
49
/// immediate Value in the MCInst.
50
///
51
/// @param Value      - The immediate Value, has had any PC adjustment made by
52
///                     the caller.
53
/// @param isBranch   - If the instruction is a branch instruction
54
/// @param Address    - The starting address of the instruction
55
/// @param Offset     - The byte offset to this immediate in the instruction
56
/// @param Width      - The byte width of this immediate in the instruction
57
///
58
/// If the getOpInfo() function was set when setupForSymbolicDisassembly() was
59
/// called then that function is called to get any symbolic information for the
60
/// immediate in the instruction using the Address, Offset and Width.  If that
61
/// returns non-zero then the symbolic information it returns is used to create
62
/// an MCExpr and that is added as an operand to the MCInst.  If getOpInfo()
63
/// returns zero and isBranch is true then a symbol look up for immediate Value
64
/// is done and if a symbol is found an MCExpr is created with that, else
65
/// an MCExpr with the immediate Value is created.  This function returns true
66
/// if it adds an operand to the MCInst and false otherwise.
67
static bool tryAddingSymbolicOperand(int64_t Value, bool IsBranch,
68
             uint64_t Address, uint64_t Offset,
69
             uint64_t Width, MCInst *MI,
70
             const void *Decoder)
71
6.46k
{
72
  // return Decoder->tryAddingSymbolicOperand(MI, Value, Address, IsBranch,
73
  //           Offset, Width, /*InstSize=*/0);
74
6.46k
  return false;
75
6.46k
}
76
77
static DecodeStatus decodeRegisterClass(MCInst *Inst, uint64_t RegNo,
78
          const unsigned *Regs, unsigned Size,
79
          bool IsAddr)
80
367k
{
81
367k
  CS_ASSERT_RET_VAL(RegNo < Size, MCDisassembler_Fail);
82
367k
  if (IsAddr && RegNo == 0) {
83
43.1k
    RegNo = SystemZ_NoRegister;
84
324k
  } else {
85
324k
    RegNo = Regs[RegNo];
86
324k
    if (RegNo == 0)
87
201
      return MCDisassembler_Fail;
88
324k
  }
89
367k
  MCOperand_CreateReg0(Inst, (RegNo));
90
367k
  return MCDisassembler_Success;
91
367k
}
92
93
static DecodeStatus DecodeGR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
94
                 uint64_t Address,
95
                 const void *Decoder)
96
70.6k
{
97
70.6k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR32Regs, 16, false);
98
70.6k
}
99
100
static DecodeStatus DecodeGRH32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
101
            uint64_t Address,
102
            const void *Decoder)
103
10.4k
{
104
10.4k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GRH32Regs, 16, false);
105
10.4k
}
106
107
static DecodeStatus DecodeGR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
108
                 uint64_t Address,
109
                 const void *Decoder)
110
42.5k
{
111
42.5k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR64Regs, 16, false);
112
42.5k
}
113
114
static DecodeStatus DecodeGR128BitRegisterClass(MCInst *Inst, uint64_t RegNo,
115
            uint64_t Address,
116
            const void *Decoder)
117
17.5k
{
118
17.5k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR128Regs, 16, false);
119
17.5k
}
120
121
static DecodeStatus DecodeADDR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
122
             uint64_t Address,
123
             const void *Decoder)
124
6.39k
{
125
6.39k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR32Regs, 16, true);
126
6.39k
}
127
128
static DecodeStatus DecodeADDR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
129
             uint64_t Address,
130
             const void *Decoder)
131
122k
{
132
122k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR64Regs, 16, true);
133
122k
}
134
135
static DecodeStatus DecodeFP32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
136
                 uint64_t Address,
137
                 const void *Decoder)
138
25.7k
{
139
25.7k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_FP32Regs, 16, false);
140
25.7k
}
141
142
static DecodeStatus DecodeFP64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
143
                 uint64_t Address,
144
                 const void *Decoder)
145
34.0k
{
146
34.0k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_FP64Regs, 16, false);
147
34.0k
}
148
149
static DecodeStatus DecodeFP128BitRegisterClass(MCInst *Inst, uint64_t RegNo,
150
            uint64_t Address,
151
            const void *Decoder)
152
7.66k
{
153
7.66k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_FP128Regs, 16, false);
154
7.66k
}
155
156
static DecodeStatus DecodeVR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
157
                 uint64_t Address,
158
                 const void *Decoder)
159
900
{
160
900
  return decodeRegisterClass(Inst, RegNo, SystemZMC_VR32Regs, 32, false);
161
900
}
162
163
static DecodeStatus DecodeVR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
164
                 uint64_t Address,
165
                 const void *Decoder)
166
1.75k
{
167
1.75k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_VR64Regs, 32, false);
168
1.75k
}
169
170
static DecodeStatus DecodeVR128BitRegisterClass(MCInst *Inst, uint64_t RegNo,
171
            uint64_t Address,
172
            const void *Decoder)
173
22.9k
{
174
22.9k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_VR128Regs, 32, false);
175
22.9k
}
176
177
static DecodeStatus DecodeAR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
178
                 uint64_t Address,
179
                 const void *Decoder)
180
2.17k
{
181
2.17k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_AR32Regs, 16, false);
182
2.17k
}
183
184
static DecodeStatus DecodeCR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
185
                 uint64_t Address,
186
                 const void *Decoder)
187
2.51k
{
188
2.51k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_CR64Regs, 16, false);
189
2.51k
}
190
191
#define DEFINE_decodeUImmOperand(N) \
192
  static DecodeStatus CONCAT(decodeUImmOperand, N)(MCInst * Inst, \
193
               uint64_t Imm) \
194
121k
  { \
195
121k
    if (!isUIntN(N, Imm)) \
196
121k
      return MCDisassembler_Fail; \
197
121k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
121k
    return MCDisassembler_Success; \
199
121k
  }
SystemZDisassembler.c:decodeUImmOperand_4
Line
Count
Source
194
28.3k
  { \
195
28.3k
    if (!isUIntN(N, Imm)) \
196
28.3k
      return MCDisassembler_Fail; \
197
28.3k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
28.3k
    return MCDisassembler_Success; \
199
28.3k
  }
SystemZDisassembler.c:decodeUImmOperand_8
Line
Count
Source
194
10.3k
  { \
195
10.3k
    if (!isUIntN(N, Imm)) \
196
10.3k
      return MCDisassembler_Fail; \
197
10.3k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
10.3k
    return MCDisassembler_Success; \
199
10.3k
  }
SystemZDisassembler.c:decodeUImmOperand_12
Line
Count
Source
194
75.7k
  { \
195
75.7k
    if (!isUIntN(N, Imm)) \
196
75.7k
      return MCDisassembler_Fail; \
197
75.7k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
75.7k
    return MCDisassembler_Success; \
199
75.7k
  }
SystemZDisassembler.c:decodeUImmOperand_16
Line
Count
Source
194
2.66k
  { \
195
2.66k
    if (!isUIntN(N, Imm)) \
196
2.66k
      return MCDisassembler_Fail; \
197
2.66k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
2.66k
    return MCDisassembler_Success; \
199
2.66k
  }
SystemZDisassembler.c:decodeUImmOperand_32
Line
Count
Source
194
1.64k
  { \
195
1.64k
    if (!isUIntN(N, Imm)) \
196
1.64k
      return MCDisassembler_Fail; \
197
1.64k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
1.64k
    return MCDisassembler_Success; \
199
1.64k
  }
SystemZDisassembler.c:decodeUImmOperand_3
Line
Count
Source
194
669
  { \
195
669
    if (!isUIntN(N, Imm)) \
196
669
      return MCDisassembler_Fail; \
197
669
    MCOperand_CreateImm0(Inst, (Imm)); \
198
665
    return MCDisassembler_Success; \
199
669
  }
SystemZDisassembler.c:decodeUImmOperand_1
Line
Count
Source
194
1.82k
  { \
195
1.82k
    if (!isUIntN(N, Imm)) \
196
1.82k
      return MCDisassembler_Fail; \
197
1.82k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
1.81k
    return MCDisassembler_Success; \
199
1.82k
  }
SystemZDisassembler.c:decodeUImmOperand_2
Line
Count
Source
194
673
  { \
195
673
    if (!isUIntN(N, Imm)) \
196
673
      return MCDisassembler_Fail; \
197
673
    MCOperand_CreateImm0(Inst, (Imm)); \
198
664
    return MCDisassembler_Success; \
199
673
  }
200
DEFINE_decodeUImmOperand(1);
201
DEFINE_decodeUImmOperand(2);
202
DEFINE_decodeUImmOperand(3);
203
DEFINE_decodeUImmOperand(4);
204
DEFINE_decodeUImmOperand(8);
205
DEFINE_decodeUImmOperand(12);
206
DEFINE_decodeUImmOperand(16);
207
DEFINE_decodeUImmOperand(32);
208
209
#define DEFINE_decodeSImmOperand(N) \
210
  static DecodeStatus CONCAT(decodeSImmOperand, N)(MCInst * Inst, \
211
               uint64_t Imm) \
212
19.2k
  { \
213
19.2k
    if (!isUIntN(N, Imm)) \
214
19.2k
      return MCDisassembler_Fail; \
215
19.2k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
19.2k
    return MCDisassembler_Success; \
217
19.2k
  }
SystemZDisassembler.c:decodeSImmOperand_16
Line
Count
Source
212
3.37k
  { \
213
3.37k
    if (!isUIntN(N, Imm)) \
214
3.37k
      return MCDisassembler_Fail; \
215
3.37k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
3.37k
    return MCDisassembler_Success; \
217
3.37k
  }
SystemZDisassembler.c:decodeSImmOperand_32
Line
Count
Source
212
1.45k
  { \
213
1.45k
    if (!isUIntN(N, Imm)) \
214
1.45k
      return MCDisassembler_Fail; \
215
1.45k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
1.45k
    return MCDisassembler_Success; \
217
1.45k
  }
SystemZDisassembler.c:decodeSImmOperand_20
Line
Count
Source
212
12.5k
  { \
213
12.5k
    if (!isUIntN(N, Imm)) \
214
12.5k
      return MCDisassembler_Fail; \
215
12.5k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
12.5k
    return MCDisassembler_Success; \
217
12.5k
  }
SystemZDisassembler.c:decodeSImmOperand_8
Line
Count
Source
212
1.87k
  { \
213
1.87k
    if (!isUIntN(N, Imm)) \
214
1.87k
      return MCDisassembler_Fail; \
215
1.87k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
1.87k
    return MCDisassembler_Success; \
217
1.87k
  }
218
DEFINE_decodeSImmOperand(8);
219
DEFINE_decodeSImmOperand(16);
220
DEFINE_decodeSImmOperand(20);
221
DEFINE_decodeSImmOperand(32);
222
223
static DecodeStatus decodeU1ImmOperand(MCInst *Inst, uint64_t Imm,
224
               uint64_t Address, const void *Decoder)
225
1.82k
{
226
1.82k
  return CONCAT(decodeUImmOperand, 1)(Inst, Imm);
227
1.82k
}
228
229
static DecodeStatus decodeU2ImmOperand(MCInst *Inst, uint64_t Imm,
230
               uint64_t Address, const void *Decoder)
231
673
{
232
673
  return CONCAT(decodeUImmOperand, 2)(Inst, Imm);
233
673
}
234
235
static DecodeStatus decodeU3ImmOperand(MCInst *Inst, uint64_t Imm,
236
               uint64_t Address, const void *Decoder)
237
669
{
238
669
  return CONCAT(decodeUImmOperand, 3)(Inst, Imm);
239
669
}
240
241
static DecodeStatus decodeU4ImmOperand(MCInst *Inst, uint64_t Imm,
242
               uint64_t Address, const void *Decoder)
243
28.3k
{
244
28.3k
  return CONCAT(decodeUImmOperand, 4)(Inst, Imm);
245
28.3k
}
246
247
static DecodeStatus decodeU8ImmOperand(MCInst *Inst, uint64_t Imm,
248
               uint64_t Address, const void *Decoder)
249
10.3k
{
250
10.3k
  return CONCAT(decodeUImmOperand, 8)(Inst, Imm);
251
10.3k
}
252
253
static DecodeStatus decodeU12ImmOperand(MCInst *Inst, uint64_t Imm,
254
          uint64_t Address, const void *Decoder)
255
75.7k
{
256
75.7k
  return CONCAT(decodeUImmOperand, 12)(Inst, Imm);
257
75.7k
}
258
259
static DecodeStatus decodeU16ImmOperand(MCInst *Inst, uint64_t Imm,
260
          uint64_t Address, const void *Decoder)
261
2.66k
{
262
2.66k
  return CONCAT(decodeUImmOperand, 16)(Inst, Imm);
263
2.66k
}
264
265
static DecodeStatus decodeU32ImmOperand(MCInst *Inst, uint64_t Imm,
266
          uint64_t Address, const void *Decoder)
267
1.64k
{
268
1.64k
  return CONCAT(decodeUImmOperand, 32)(Inst, Imm);
269
1.64k
}
270
271
static DecodeStatus decodeS8ImmOperand(MCInst *Inst, uint64_t Imm,
272
               uint64_t Address, const void *Decoder)
273
1.87k
{
274
1.87k
  return CONCAT(decodeSImmOperand, 8)(Inst, Imm);
275
1.87k
}
276
277
static DecodeStatus decodeS16ImmOperand(MCInst *Inst, uint64_t Imm,
278
          uint64_t Address, const void *Decoder)
279
3.37k
{
280
3.37k
  return CONCAT(decodeSImmOperand, 16)(Inst, Imm);
281
3.37k
}
282
283
static DecodeStatus decodeS20ImmOperand(MCInst *Inst, uint64_t Imm,
284
          uint64_t Address, const void *Decoder)
285
12.5k
{
286
12.5k
  return CONCAT(decodeSImmOperand, 20)(Inst, Imm);
287
12.5k
}
288
289
static DecodeStatus decodeS32ImmOperand(MCInst *Inst, uint64_t Imm,
290
          uint64_t Address, const void *Decoder)
291
1.45k
{
292
1.45k
  return CONCAT(decodeSImmOperand, 32)(Inst, Imm);
293
1.45k
}
294
295
#define DEFINE_decodeLenOperand(N) \
296
  static DecodeStatus CONCAT(decodeLenOperand, \
297
           N)(MCInst * Inst, uint64_t Imm, \
298
              uint64_t Address, const void *Decoder) \
299
11.2k
  { \
300
11.2k
    if (!isUIntN(N, Imm)) \
301
11.2k
      return MCDisassembler_Fail; \
302
11.2k
    MCOperand_CreateImm0(Inst, (Imm + 1)); \
303
11.2k
    return MCDisassembler_Success; \
304
11.2k
  }
SystemZDisassembler.c:decodeLenOperand_8
Line
Count
Source
299
4.78k
  { \
300
4.78k
    if (!isUIntN(N, Imm)) \
301
4.78k
      return MCDisassembler_Fail; \
302
4.78k
    MCOperand_CreateImm0(Inst, (Imm + 1)); \
303
4.78k
    return MCDisassembler_Success; \
304
4.78k
  }
SystemZDisassembler.c:decodeLenOperand_4
Line
Count
Source
299
6.45k
  { \
300
6.45k
    if (!isUIntN(N, Imm)) \
301
6.45k
      return MCDisassembler_Fail; \
302
6.45k
    MCOperand_CreateImm0(Inst, (Imm + 1)); \
303
6.45k
    return MCDisassembler_Success; \
304
6.45k
  }
305
DEFINE_decodeLenOperand(8);
306
DEFINE_decodeLenOperand(4);
307
308
#define DEFINE_decodePCDBLOperand(N) \
309
  static DecodeStatus CONCAT(decodePCDBLOperand, N)( \
310
    MCInst * Inst, uint64_t Imm, uint64_t Address, bool isBranch, \
311
    const void *Decoder) \
312
6.46k
  { \
313
6.46k
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
6.46k
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
6.46k
\
316
6.46k
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
6.46k
                N / 8, Inst, Decoder)) \
318
6.46k
      MCOperand_CreateImm0(Inst, (Value)); \
319
6.46k
\
320
6.46k
    return MCDisassembler_Success; \
321
6.46k
  }
SystemZDisassembler.c:decodePCDBLOperand_16
Line
Count
Source
312
3.65k
  { \
313
3.65k
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
3.65k
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
3.65k
\
316
3.65k
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
3.65k
                N / 8, Inst, Decoder)) \
318
3.65k
      MCOperand_CreateImm0(Inst, (Value)); \
319
3.65k
\
320
3.65k
    return MCDisassembler_Success; \
321
3.65k
  }
SystemZDisassembler.c:decodePCDBLOperand_32
Line
Count
Source
312
2.30k
  { \
313
2.30k
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
2.30k
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
2.30k
\
316
2.30k
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
2.30k
                N / 8, Inst, Decoder)) \
318
2.30k
      MCOperand_CreateImm0(Inst, (Value)); \
319
2.30k
\
320
2.30k
    return MCDisassembler_Success; \
321
2.30k
  }
SystemZDisassembler.c:decodePCDBLOperand_12
Line
Count
Source
312
251
  { \
313
251
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
251
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
251
\
316
251
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
251
                N / 8, Inst, Decoder)) \
318
251
      MCOperand_CreateImm0(Inst, (Value)); \
319
251
\
320
251
    return MCDisassembler_Success; \
321
251
  }
SystemZDisassembler.c:decodePCDBLOperand_24
Line
Count
Source
312
251
  { \
313
251
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
251
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
251
\
316
251
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
251
                N / 8, Inst, Decoder)) \
318
251
      MCOperand_CreateImm0(Inst, (Value)); \
319
251
\
320
251
    return MCDisassembler_Success; \
321
251
  }
322
DEFINE_decodePCDBLOperand(12);
323
DEFINE_decodePCDBLOperand(16);
324
DEFINE_decodePCDBLOperand(24);
325
DEFINE_decodePCDBLOperand(32);
326
327
static DecodeStatus decodePC12DBLBranchOperand(MCInst *Inst, uint64_t Imm,
328
                 uint64_t Address,
329
                 const void *Decoder)
330
251
{
331
251
  return CONCAT(decodePCDBLOperand, 12)(Inst, Imm, Address, true,
332
251
                Decoder);
333
251
}
334
335
static DecodeStatus decodePC16DBLBranchOperand(MCInst *Inst, uint64_t Imm,
336
                 uint64_t Address,
337
                 const void *Decoder)
338
3.65k
{
339
3.65k
  return CONCAT(decodePCDBLOperand, 16)(Inst, Imm, Address, true,
340
3.65k
                Decoder);
341
3.65k
}
342
343
static DecodeStatus decodePC24DBLBranchOperand(MCInst *Inst, uint64_t Imm,
344
                 uint64_t Address,
345
                 const void *Decoder)
346
251
{
347
251
  return CONCAT(decodePCDBLOperand, 24)(Inst, Imm, Address, true,
348
251
                Decoder);
349
251
}
350
351
static DecodeStatus decodePC32DBLBranchOperand(MCInst *Inst, uint64_t Imm,
352
                 uint64_t Address,
353
                 const void *Decoder)
354
443
{
355
443
  return CONCAT(decodePCDBLOperand, 32)(Inst, Imm, Address, true,
356
443
                Decoder);
357
443
}
358
359
static DecodeStatus decodePC32DBLOperand(MCInst *Inst, uint64_t Imm,
360
           uint64_t Address, const void *Decoder)
361
1.86k
{
362
1.86k
  return CONCAT(decodePCDBLOperand, 32)(Inst, Imm, Address, false,
363
1.86k
                Decoder);
364
1.86k
}
365
366
#include "SystemZGenDisassemblerTables.inc"
367
368
static DecodeStatus getInstruction(MCInst *MI, uint16_t *Size,
369
           const uint8_t *Bytes, size_t BytesLen,
370
           uint64_t Address, SStream *CS)
371
149k
{
372
  // Get the first two bytes of the instruction.
373
149k
  *Size = 0;
374
149k
  if (BytesLen < 2)
375
747
    return MCDisassembler_Fail;
376
377
  // The top 2 bits of the first byte specify the size.
378
148k
  const uint8_t *Table;
379
148k
  uint64_t Inst = 0;
380
148k
  if (Bytes[0] < 0x40) {
381
38.1k
    *Size = 2;
382
38.1k
    Table = DecoderTable16;
383
38.1k
    Inst = readBytes16(MI, Bytes);
384
110k
  } else if (Bytes[0] < 0xc0) {
385
52.8k
    if (BytesLen < 4) {
386
286
      return MCDisassembler_Fail;
387
286
    }
388
52.5k
    *Size = 4;
389
52.5k
    Table = DecoderTable32;
390
52.5k
    Inst = readBytes32(MI, Bytes);
391
57.7k
  } else {
392
57.7k
    if (BytesLen < 6) {
393
374
      return MCDisassembler_Fail;
394
374
    }
395
57.4k
    *Size = 6;
396
57.4k
    Table = DecoderTable48;
397
57.4k
    Inst = readBytes48(MI, Bytes);
398
57.4k
  }
399
400
  // Read any remaining bytes.
401
148k
  if (BytesLen < *Size) {
402
0
    *Size = BytesLen;
403
0
    return MCDisassembler_Fail;
404
0
  }
405
406
148k
  return decodeInstruction_8(Table, MI, Inst, Address, NULL);
407
148k
}
408
409
DecodeStatus SystemZ_LLVM_getInstruction(csh handle, const uint8_t *Bytes,
410
           size_t BytesLen, MCInst *MI,
411
           uint16_t *Size, uint64_t Address,
412
           void *Info)
413
149k
{
414
  return getInstruction(MI, Size, Bytes, BytesLen, MI->address, NULL);
415
149k
}