Coverage Report

Created: 2026-03-03 06:14

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
56.5k
#define CONCAT(a, b) CONCAT_(a, b)
40
56.5k
#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
2.03k
{
72
  // return Decoder->tryAddingSymbolicOperand(MI, Value, Address, IsBranch,
73
  //           Offset, Width, /*InstSize=*/0);
74
2.03k
  return false;
75
2.03k
}
76
77
static DecodeStatus decodeRegisterClass(MCInst *Inst, uint64_t RegNo,
78
          const unsigned *Regs, unsigned Size,
79
          bool IsAddr)
80
147k
{
81
147k
  CS_ASSERT((RegNo < Size && "Invalid register"));
82
147k
  if (IsAddr && RegNo == 0) {
83
16.1k
    RegNo = SystemZ_NoRegister;
84
131k
  } else {
85
131k
    RegNo = Regs[RegNo];
86
131k
    if (RegNo == 0)
87
104
      return MCDisassembler_Fail;
88
131k
  }
89
147k
  MCOperand_CreateReg0(Inst, (RegNo));
90
147k
  return MCDisassembler_Success;
91
147k
}
92
93
static DecodeStatus DecodeGR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
94
                 uint64_t Address,
95
                 const void *Decoder)
96
23.1k
{
97
23.1k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR32Regs, 16, false);
98
23.1k
}
99
100
static DecodeStatus DecodeGRH32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
101
            uint64_t Address,
102
            const void *Decoder)
103
4.45k
{
104
4.45k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GRH32Regs, 16, false);
105
4.45k
}
106
107
static DecodeStatus DecodeGR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
108
                 uint64_t Address,
109
                 const void *Decoder)
110
15.1k
{
111
15.1k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR64Regs, 16, false);
112
15.1k
}
113
114
static DecodeStatus DecodeGR128BitRegisterClass(MCInst *Inst, uint64_t RegNo,
115
            uint64_t Address,
116
            const void *Decoder)
117
6.95k
{
118
6.95k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR128Regs, 16, false);
119
6.95k
}
120
121
static DecodeStatus DecodeADDR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
122
             uint64_t Address,
123
             const void *Decoder)
124
2.11k
{
125
2.11k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR32Regs, 16, true);
126
2.11k
}
127
128
static DecodeStatus DecodeADDR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
129
             uint64_t Address,
130
             const void *Decoder)
131
43.3k
{
132
43.3k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_GR64Regs, 16, true);
133
43.3k
}
134
135
static DecodeStatus DecodeFP32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
136
                 uint64_t Address,
137
                 const void *Decoder)
138
13.2k
{
139
13.2k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_FP32Regs, 16, false);
140
13.2k
}
141
142
static DecodeStatus DecodeFP64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
143
                 uint64_t Address,
144
                 const void *Decoder)
145
16.7k
{
146
16.7k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_FP64Regs, 16, false);
147
16.7k
}
148
149
static DecodeStatus DecodeFP128BitRegisterClass(MCInst *Inst, uint64_t RegNo,
150
            uint64_t Address,
151
            const void *Decoder)
152
5.16k
{
153
5.16k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_FP128Regs, 16, false);
154
5.16k
}
155
156
static DecodeStatus DecodeVR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
157
                 uint64_t Address,
158
                 const void *Decoder)
159
1.83k
{
160
1.83k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_VR32Regs, 32, false);
161
1.83k
}
162
163
static DecodeStatus DecodeVR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
164
                 uint64_t Address,
165
                 const void *Decoder)
166
697
{
167
697
  return decodeRegisterClass(Inst, RegNo, SystemZMC_VR64Regs, 32, false);
168
697
}
169
170
static DecodeStatus DecodeVR128BitRegisterClass(MCInst *Inst, uint64_t RegNo,
171
            uint64_t Address,
172
            const void *Decoder)
173
11.9k
{
174
11.9k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_VR128Regs, 32, false);
175
11.9k
}
176
177
static DecodeStatus DecodeAR32BitRegisterClass(MCInst *Inst, uint64_t RegNo,
178
                 uint64_t Address,
179
                 const void *Decoder)
180
1.79k
{
181
1.79k
  return decodeRegisterClass(Inst, RegNo, SystemZMC_AR32Regs, 16, false);
182
1.79k
}
183
184
static DecodeStatus DecodeCR64BitRegisterClass(MCInst *Inst, uint64_t RegNo,
185
                 uint64_t Address,
186
                 const void *Decoder)
187
724
{
188
724
  return decodeRegisterClass(Inst, RegNo, SystemZMC_CR64Regs, 16, false);
189
724
}
190
191
#define DEFINE_decodeUImmOperand(N) \
192
  static DecodeStatus CONCAT(decodeUImmOperand, N)(MCInst * Inst, \
193
               uint64_t Imm) \
194
45.6k
  { \
195
45.6k
    if (!isUIntN(N, Imm)) \
196
45.6k
      return MCDisassembler_Fail; \
197
45.6k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
45.6k
    return MCDisassembler_Success; \
199
45.6k
  }
SystemZDisassembler.c:decodeUImmOperand_4
Line
Count
Source
194
13.2k
  { \
195
13.2k
    if (!isUIntN(N, Imm)) \
196
13.2k
      return MCDisassembler_Fail; \
197
13.2k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
13.2k
    return MCDisassembler_Success; \
199
13.2k
  }
SystemZDisassembler.c:decodeUImmOperand_8
Line
Count
Source
194
3.28k
  { \
195
3.28k
    if (!isUIntN(N, Imm)) \
196
3.28k
      return MCDisassembler_Fail; \
197
3.28k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
3.28k
    return MCDisassembler_Success; \
199
3.28k
  }
SystemZDisassembler.c:decodeUImmOperand_12
Line
Count
Source
194
26.0k
  { \
195
26.0k
    if (!isUIntN(N, Imm)) \
196
26.0k
      return MCDisassembler_Fail; \
197
26.0k
    MCOperand_CreateImm0(Inst, (Imm)); \
198
26.0k
    return MCDisassembler_Success; \
199
26.0k
  }
SystemZDisassembler.c:decodeUImmOperand_16
Line
Count
Source
194
916
  { \
195
916
    if (!isUIntN(N, Imm)) \
196
916
      return MCDisassembler_Fail; \
197
916
    MCOperand_CreateImm0(Inst, (Imm)); \
198
916
    return MCDisassembler_Success; \
199
916
  }
SystemZDisassembler.c:decodeUImmOperand_32
Line
Count
Source
194
501
  { \
195
501
    if (!isUIntN(N, Imm)) \
196
501
      return MCDisassembler_Fail; \
197
501
    MCOperand_CreateImm0(Inst, (Imm)); \
198
501
    return MCDisassembler_Success; \
199
501
  }
SystemZDisassembler.c:decodeUImmOperand_3
Line
Count
Source
194
425
  { \
195
425
    if (!isUIntN(N, Imm)) \
196
425
      return MCDisassembler_Fail; \
197
425
    MCOperand_CreateImm0(Inst, (Imm)); \
198
423
    return MCDisassembler_Success; \
199
425
  }
SystemZDisassembler.c:decodeUImmOperand_1
Line
Count
Source
194
649
  { \
195
649
    if (!isUIntN(N, Imm)) \
196
649
      return MCDisassembler_Fail; \
197
649
    MCOperand_CreateImm0(Inst, (Imm)); \
198
641
    return MCDisassembler_Success; \
199
649
  }
SystemZDisassembler.c:decodeUImmOperand_2
Line
Count
Source
194
595
  { \
195
595
    if (!isUIntN(N, Imm)) \
196
595
      return MCDisassembler_Fail; \
197
595
    MCOperand_CreateImm0(Inst, (Imm)); \
198
586
    return MCDisassembler_Success; \
199
595
  }
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
8.81k
  { \
213
8.81k
    if (!isUIntN(N, Imm)) \
214
8.81k
      return MCDisassembler_Fail; \
215
8.81k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
8.81k
    return MCDisassembler_Success; \
217
8.81k
  }
SystemZDisassembler.c:decodeSImmOperand_16
Line
Count
Source
212
1.08k
  { \
213
1.08k
    if (!isUIntN(N, Imm)) \
214
1.08k
      return MCDisassembler_Fail; \
215
1.08k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
1.08k
    return MCDisassembler_Success; \
217
1.08k
  }
SystemZDisassembler.c:decodeSImmOperand_32
Line
Count
Source
212
432
  { \
213
432
    if (!isUIntN(N, Imm)) \
214
432
      return MCDisassembler_Fail; \
215
432
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
432
    return MCDisassembler_Success; \
217
432
  }
SystemZDisassembler.c:decodeSImmOperand_20
Line
Count
Source
212
6.34k
  { \
213
6.34k
    if (!isUIntN(N, Imm)) \
214
6.34k
      return MCDisassembler_Fail; \
215
6.34k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
6.34k
    return MCDisassembler_Success; \
217
6.34k
  }
SystemZDisassembler.c:decodeSImmOperand_8
Line
Count
Source
212
956
  { \
213
956
    if (!isUIntN(N, Imm)) \
214
956
      return MCDisassembler_Fail; \
215
956
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
216
956
    return MCDisassembler_Success; \
217
956
  }
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
649
{
226
649
  return CONCAT(decodeUImmOperand, 1)(Inst, Imm);
227
649
}
228
229
static DecodeStatus decodeU2ImmOperand(MCInst *Inst, uint64_t Imm,
230
               uint64_t Address, const void *Decoder)
231
595
{
232
595
  return CONCAT(decodeUImmOperand, 2)(Inst, Imm);
233
595
}
234
235
static DecodeStatus decodeU3ImmOperand(MCInst *Inst, uint64_t Imm,
236
               uint64_t Address, const void *Decoder)
237
425
{
238
425
  return CONCAT(decodeUImmOperand, 3)(Inst, Imm);
239
425
}
240
241
static DecodeStatus decodeU4ImmOperand(MCInst *Inst, uint64_t Imm,
242
               uint64_t Address, const void *Decoder)
243
13.2k
{
244
13.2k
  return CONCAT(decodeUImmOperand, 4)(Inst, Imm);
245
13.2k
}
246
247
static DecodeStatus decodeU8ImmOperand(MCInst *Inst, uint64_t Imm,
248
               uint64_t Address, const void *Decoder)
249
3.28k
{
250
3.28k
  return CONCAT(decodeUImmOperand, 8)(Inst, Imm);
251
3.28k
}
252
253
static DecodeStatus decodeU12ImmOperand(MCInst *Inst, uint64_t Imm,
254
          uint64_t Address, const void *Decoder)
255
26.0k
{
256
26.0k
  return CONCAT(decodeUImmOperand, 12)(Inst, Imm);
257
26.0k
}
258
259
static DecodeStatus decodeU16ImmOperand(MCInst *Inst, uint64_t Imm,
260
          uint64_t Address, const void *Decoder)
261
916
{
262
916
  return CONCAT(decodeUImmOperand, 16)(Inst, Imm);
263
916
}
264
265
static DecodeStatus decodeU32ImmOperand(MCInst *Inst, uint64_t Imm,
266
          uint64_t Address, const void *Decoder)
267
501
{
268
501
  return CONCAT(decodeUImmOperand, 32)(Inst, Imm);
269
501
}
270
271
static DecodeStatus decodeS8ImmOperand(MCInst *Inst, uint64_t Imm,
272
               uint64_t Address, const void *Decoder)
273
956
{
274
956
  return CONCAT(decodeSImmOperand, 8)(Inst, Imm);
275
956
}
276
277
static DecodeStatus decodeS16ImmOperand(MCInst *Inst, uint64_t Imm,
278
          uint64_t Address, const void *Decoder)
279
1.08k
{
280
1.08k
  return CONCAT(decodeSImmOperand, 16)(Inst, Imm);
281
1.08k
}
282
283
static DecodeStatus decodeS20ImmOperand(MCInst *Inst, uint64_t Imm,
284
          uint64_t Address, const void *Decoder)
285
6.34k
{
286
6.34k
  return CONCAT(decodeSImmOperand, 20)(Inst, Imm);
287
6.34k
}
288
289
static DecodeStatus decodeS32ImmOperand(MCInst *Inst, uint64_t Imm,
290
          uint64_t Address, const void *Decoder)
291
432
{
292
432
  return CONCAT(decodeSImmOperand, 32)(Inst, Imm);
293
432
}
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
3.20k
  { \
300
3.20k
    if (!isUIntN(N, Imm)) \
301
3.20k
      return MCDisassembler_Fail; \
302
3.20k
    MCOperand_CreateImm0(Inst, (Imm + 1)); \
303
3.20k
    return MCDisassembler_Success; \
304
3.20k
  }
SystemZDisassembler.c:decodeLenOperand_8
Line
Count
Source
299
1.29k
  { \
300
1.29k
    if (!isUIntN(N, Imm)) \
301
1.29k
      return MCDisassembler_Fail; \
302
1.29k
    MCOperand_CreateImm0(Inst, (Imm + 1)); \
303
1.29k
    return MCDisassembler_Success; \
304
1.29k
  }
SystemZDisassembler.c:decodeLenOperand_4
Line
Count
Source
299
1.90k
  { \
300
1.90k
    if (!isUIntN(N, Imm)) \
301
1.90k
      return MCDisassembler_Fail; \
302
1.90k
    MCOperand_CreateImm0(Inst, (Imm + 1)); \
303
1.90k
    return MCDisassembler_Success; \
304
1.90k
  }
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
2.03k
  { \
313
2.03k
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
2.03k
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
2.03k
\
316
2.03k
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
2.03k
                N / 8, Inst, Decoder)) \
318
2.03k
      MCOperand_CreateImm0(Inst, (Value)); \
319
2.03k
\
320
2.03k
    return MCDisassembler_Success; \
321
2.03k
  }
SystemZDisassembler.c:decodePCDBLOperand_16
Line
Count
Source
312
1.04k
  { \
313
1.04k
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
1.04k
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
1.04k
\
316
1.04k
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
1.04k
                N / 8, Inst, Decoder)) \
318
1.04k
      MCOperand_CreateImm0(Inst, (Value)); \
319
1.04k
\
320
1.04k
    return MCDisassembler_Success; \
321
1.04k
  }
SystemZDisassembler.c:decodePCDBLOperand_32
Line
Count
Source
312
692
  { \
313
692
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
692
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
692
\
316
692
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
692
                N / 8, Inst, Decoder)) \
318
692
      MCOperand_CreateImm0(Inst, (Value)); \
319
692
\
320
692
    return MCDisassembler_Success; \
321
692
  }
SystemZDisassembler.c:decodePCDBLOperand_12
Line
Count
Source
312
149
  { \
313
149
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
149
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
149
\
316
149
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
149
                N / 8, Inst, Decoder)) \
318
149
      MCOperand_CreateImm0(Inst, (Value)); \
319
149
\
320
149
    return MCDisassembler_Success; \
321
149
  }
SystemZDisassembler.c:decodePCDBLOperand_24
Line
Count
Source
312
149
  { \
313
149
    CS_ASSERT((isUIntN(N, Imm) && "Invalid PC-relative offset")); \
314
149
    uint64_t Value = SignExtend64((Imm), N) * 2 + Address; \
315
149
\
316
149
    if (!tryAddingSymbolicOperand(Value, isBranch, Address, 2, \
317
149
                N / 8, Inst, Decoder)) \
318
149
      MCOperand_CreateImm0(Inst, (Value)); \
319
149
\
320
149
    return MCDisassembler_Success; \
321
149
  }
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
149
{
331
149
  return CONCAT(decodePCDBLOperand, 12)(Inst, Imm, Address, true,
332
149
                Decoder);
333
149
}
334
335
static DecodeStatus decodePC16DBLBranchOperand(MCInst *Inst, uint64_t Imm,
336
                 uint64_t Address,
337
                 const void *Decoder)
338
1.04k
{
339
1.04k
  return CONCAT(decodePCDBLOperand, 16)(Inst, Imm, Address, true,
340
1.04k
                Decoder);
341
1.04k
}
342
343
static DecodeStatus decodePC24DBLBranchOperand(MCInst *Inst, uint64_t Imm,
344
                 uint64_t Address,
345
                 const void *Decoder)
346
149
{
347
149
  return CONCAT(decodePCDBLOperand, 24)(Inst, Imm, Address, true,
348
149
                Decoder);
349
149
}
350
351
static DecodeStatus decodePC32DBLBranchOperand(MCInst *Inst, uint64_t Imm,
352
                 uint64_t Address,
353
                 const void *Decoder)
354
269
{
355
269
  return CONCAT(decodePCDBLOperand, 32)(Inst, Imm, Address, true,
356
269
                Decoder);
357
269
}
358
359
static DecodeStatus decodePC32DBLOperand(MCInst *Inst, uint64_t Imm,
360
           uint64_t Address, const void *Decoder)
361
423
{
362
423
  return CONCAT(decodePCDBLOperand, 32)(Inst, Imm, Address, false,
363
423
                Decoder);
364
423
}
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
58.5k
{
372
  // Get the first two bytes of the instruction.
373
58.5k
  *Size = 0;
374
58.5k
  if (BytesLen < 2)
375
351
    return MCDisassembler_Fail;
376
377
  // The top 2 bits of the first byte specify the size.
378
58.1k
  const uint8_t *Table;
379
58.1k
  uint64_t Inst = 0;
380
58.1k
  if (Bytes[0] < 0x40) {
381
14.7k
    *Size = 2;
382
14.7k
    Table = DecoderTable16;
383
14.7k
    Inst = readBytes16(MI, Bytes);
384
43.4k
  } else if (Bytes[0] < 0xc0) {
385
19.0k
    if (BytesLen < 4) {
386
120
      return MCDisassembler_Fail;
387
120
    }
388
18.9k
    *Size = 4;
389
18.9k
    Table = DecoderTable32;
390
18.9k
    Inst = readBytes32(MI, Bytes);
391
24.4k
  } else {
392
24.4k
    if (BytesLen < 6) {
393
168
      return MCDisassembler_Fail;
394
168
    }
395
24.2k
    *Size = 6;
396
24.2k
    Table = DecoderTable48;
397
24.2k
    Inst = readBytes48(MI, Bytes);
398
24.2k
  }
399
400
  // Read any remaining bytes.
401
57.8k
  if (BytesLen < *Size) {
402
0
    *Size = BytesLen;
403
0
    return MCDisassembler_Fail;
404
0
  }
405
406
57.8k
  return decodeInstruction_8(Table, MI, Inst, Address, NULL);
407
57.8k
}
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
58.5k
{
414
  return getInstruction(MI, Size, Bytes, BytesLen, MI->address, NULL);
415
58.5k
}