1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* * BPF Disassembler *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9
10#include "llvm/MC/MCInst.h"
11#include "llvm/MC/MCSubtargetInfo.h"
12#include "llvm/Support/DataTypes.h"
13#include "llvm/Support/Debug.h"
14#include "llvm/Support/LEB128.h"
15#include "llvm/Support/raw_ostream.h"
16#include "llvm/TargetParser/SubtargetFeature.h"
17#include <assert.h>
18
19namespace llvm {
20
21// Helper functions for extracting fields from encoded instructions.
22// InsnType must either be integral or an APInt-like object that must:
23// * be default-constructible and copy-constructible
24// * be constructible from an APInt (this can be private)
25// * Support insertBits(bits, startBit, numBits)
26// * Support extractBitsAsZExtValue(numBits, startBit)
27// * Support the ~, &, ==, and != operators with other objects of the same type
28// * Support the != and bitwise & with uint64_t
29// * Support put (<<) to raw_ostream&
30template <typename InsnType>
31#if defined(_MSC_VER) && !defined(__clang__)
32__declspec(noinline)
33#endif
34static std::enable_if_t<std::is_integral<InsnType>::value, InsnType>
35fieldFromInstruction(const InsnType &insn, unsigned startBit,
36 unsigned numBits) {
37 assert(startBit + numBits <= 64 && "Cannot support >64-bit extractions!");
38 assert(startBit + numBits <= (sizeof(InsnType) * 8) &&
39 "Instruction field out of bounds!");
40 InsnType fieldMask;
41 if (numBits == sizeof(InsnType) * 8)
42 fieldMask = (InsnType)(-1LL);
43 else
44 fieldMask = (((InsnType)1 << numBits) - 1) << startBit;
45 return (insn & fieldMask) >> startBit;
46}
47
48template <typename InsnType>
49static std::enable_if_t<!std::is_integral<InsnType>::value, uint64_t>
50fieldFromInstruction(const InsnType &insn, unsigned startBit,
51 unsigned numBits) {
52 return insn.extractBitsAsZExtValue(numBits, startBit);
53}
54
55// Helper function for inserting bits extracted from an encoded instruction into
56// a field.
57template <typename InsnType>
58static std::enable_if_t<std::is_integral<InsnType>::value>
59insertBits(InsnType &field, InsnType bits, unsigned startBit, unsigned numBits) {
60 assert(startBit + numBits <= sizeof field * 8);
61 field |= (InsnType)bits << startBit;
62}
63
64template <typename InsnType>
65static std::enable_if_t<!std::is_integral<InsnType>::value>
66insertBits(InsnType &field, uint64_t bits, unsigned startBit, unsigned numBits) {
67 field.insertBits(bits, startBit, numBits);
68}
69
70static bool Check(DecodeStatus &Out, DecodeStatus In) {
71 Out = static_cast<DecodeStatus>(Out & In);
72 return Out != MCDisassembler::Fail;
73}
74
75static const uint8_t DecoderTableBPF64[] = {
76/* 0 */ MCD::OPC_ExtractField, 56, 8, // Inst{63-56} ...
77/* 3 */ MCD::OPC_FilterValue, 4, 11, 0, 0, // Skip to: 19
78/* 8 */ MCD::OPC_CheckField, 32, 16, 0, 79, 7, 0, // Skip to: 1886
79/* 15 */ MCD::OPC_Decode, 181, 2, 0, // Opcode: ADD_ri_32
80/* 19 */ MCD::OPC_FilterValue, 5, 4, 0, 0, // Skip to: 28
81/* 24 */ MCD::OPC_Decode, 211, 2, 1, // Opcode: JMP
82/* 28 */ MCD::OPC_FilterValue, 6, 4, 0, 0, // Skip to: 37
83/* 33 */ MCD::OPC_Decode, 212, 2, 2, // Opcode: JMPL
84/* 37 */ MCD::OPC_FilterValue, 7, 11, 0, 0, // Skip to: 53
85/* 42 */ MCD::OPC_CheckField, 32, 16, 0, 45, 7, 0, // Skip to: 1886
86/* 49 */ MCD::OPC_Decode, 180, 2, 3, // Opcode: ADD_ri
87/* 53 */ MCD::OPC_FilterValue, 12, 11, 0, 0, // Skip to: 69
88/* 58 */ MCD::OPC_CheckField, 32, 16, 0, 29, 7, 0, // Skip to: 1886
89/* 65 */ MCD::OPC_Decode, 183, 2, 4, // Opcode: ADD_rr_32
90/* 69 */ MCD::OPC_FilterValue, 15, 11, 0, 0, // Skip to: 85
91/* 74 */ MCD::OPC_CheckField, 32, 16, 0, 13, 7, 0, // Skip to: 1886
92/* 81 */ MCD::OPC_Decode, 182, 2, 5, // Opcode: ADD_rr
93/* 85 */ MCD::OPC_FilterValue, 20, 11, 0, 0, // Skip to: 101
94/* 90 */ MCD::OPC_CheckField, 32, 16, 0, 253, 6, 0, // Skip to: 1886
95/* 97 */ MCD::OPC_Decode, 204, 3, 0, // Opcode: SUB_ri_32
96/* 101 */ MCD::OPC_FilterValue, 21, 4, 0, 0, // Skip to: 110
97/* 106 */ MCD::OPC_Decode, 207, 2, 6, // Opcode: JEQ_ri
98/* 110 */ MCD::OPC_FilterValue, 22, 4, 0, 0, // Skip to: 119
99/* 115 */ MCD::OPC_Decode, 208, 2, 7, // Opcode: JEQ_ri_32
100/* 119 */ MCD::OPC_FilterValue, 23, 11, 0, 0, // Skip to: 135
101/* 124 */ MCD::OPC_CheckField, 32, 16, 0, 219, 6, 0, // Skip to: 1886
102/* 131 */ MCD::OPC_Decode, 203, 3, 3, // Opcode: SUB_ri
103/* 135 */ MCD::OPC_FilterValue, 24, 23, 0, 0, // Skip to: 163
104/* 140 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
105/* 143 */ MCD::OPC_FilterValue, 0, 202, 6, 0, // Skip to: 1886
106/* 148 */ MCD::OPC_CheckField, 52, 4, 0, 4, 0, 0, // Skip to: 159
107/* 155 */ MCD::OPC_Decode, 141, 3, 8, // Opcode: LD_imm64
108/* 159 */ MCD::OPC_Decode, 142, 3, 9, // Opcode: LD_pseudo
109/* 163 */ MCD::OPC_FilterValue, 28, 11, 0, 0, // Skip to: 179
110/* 168 */ MCD::OPC_CheckField, 32, 16, 0, 175, 6, 0, // Skip to: 1886
111/* 175 */ MCD::OPC_Decode, 206, 3, 4, // Opcode: SUB_rr_32
112/* 179 */ MCD::OPC_FilterValue, 29, 4, 0, 0, // Skip to: 188
113/* 184 */ MCD::OPC_Decode, 209, 2, 10, // Opcode: JEQ_rr
114/* 188 */ MCD::OPC_FilterValue, 30, 4, 0, 0, // Skip to: 197
115/* 193 */ MCD::OPC_Decode, 210, 2, 11, // Opcode: JEQ_rr_32
116/* 197 */ MCD::OPC_FilterValue, 31, 11, 0, 0, // Skip to: 213
117/* 202 */ MCD::OPC_CheckField, 32, 16, 0, 141, 6, 0, // Skip to: 1886
118/* 209 */ MCD::OPC_Decode, 205, 3, 5, // Opcode: SUB_rr
119/* 213 */ MCD::OPC_FilterValue, 32, 4, 0, 0, // Skip to: 222
120/* 218 */ MCD::OPC_Decode, 137, 3, 2, // Opcode: LD_ABS_W
121/* 222 */ MCD::OPC_FilterValue, 36, 11, 0, 0, // Skip to: 238
122/* 227 */ MCD::OPC_CheckField, 32, 16, 0, 116, 6, 0, // Skip to: 1886
123/* 234 */ MCD::OPC_Decode, 161, 3, 0, // Opcode: MUL_ri_32
124/* 238 */ MCD::OPC_FilterValue, 37, 4, 0, 0, // Skip to: 247
125/* 243 */ MCD::OPC_Decode, 241, 2, 6, // Opcode: JUGT_ri
126/* 247 */ MCD::OPC_FilterValue, 38, 4, 0, 0, // Skip to: 256
127/* 252 */ MCD::OPC_Decode, 242, 2, 7, // Opcode: JUGT_ri_32
128/* 256 */ MCD::OPC_FilterValue, 39, 11, 0, 0, // Skip to: 272
129/* 261 */ MCD::OPC_CheckField, 32, 16, 0, 82, 6, 0, // Skip to: 1886
130/* 268 */ MCD::OPC_Decode, 160, 3, 3, // Opcode: MUL_ri
131/* 272 */ MCD::OPC_FilterValue, 40, 4, 0, 0, // Skip to: 281
132/* 277 */ MCD::OPC_Decode, 136, 3, 2, // Opcode: LD_ABS_H
133/* 281 */ MCD::OPC_FilterValue, 44, 11, 0, 0, // Skip to: 297
134/* 286 */ MCD::OPC_CheckField, 32, 16, 0, 57, 6, 0, // Skip to: 1886
135/* 293 */ MCD::OPC_Decode, 163, 3, 4, // Opcode: MUL_rr_32
136/* 297 */ MCD::OPC_FilterValue, 45, 4, 0, 0, // Skip to: 306
137/* 302 */ MCD::OPC_Decode, 243, 2, 10, // Opcode: JUGT_rr
138/* 306 */ MCD::OPC_FilterValue, 46, 4, 0, 0, // Skip to: 315
139/* 311 */ MCD::OPC_Decode, 244, 2, 11, // Opcode: JUGT_rr_32
140/* 315 */ MCD::OPC_FilterValue, 47, 11, 0, 0, // Skip to: 331
141/* 320 */ MCD::OPC_CheckField, 32, 16, 0, 23, 6, 0, // Skip to: 1886
142/* 327 */ MCD::OPC_Decode, 162, 3, 5, // Opcode: MUL_rr
143/* 331 */ MCD::OPC_FilterValue, 48, 4, 0, 0, // Skip to: 340
144/* 336 */ MCD::OPC_Decode, 135, 3, 2, // Opcode: LD_ABS_B
145/* 340 */ MCD::OPC_FilterValue, 52, 21, 0, 0, // Skip to: 366
146/* 345 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
147/* 348 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 357
148/* 353 */ MCD::OPC_Decode, 201, 2, 0, // Opcode: DIV_ri_32
149/* 357 */ MCD::OPC_FilterValue, 1, 244, 5, 0, // Skip to: 1886
150/* 362 */ MCD::OPC_Decode, 173, 3, 0, // Opcode: SDIV_ri_32
151/* 366 */ MCD::OPC_FilterValue, 53, 4, 0, 0, // Skip to: 375
152/* 371 */ MCD::OPC_Decode, 237, 2, 6, // Opcode: JUGE_ri
153/* 375 */ MCD::OPC_FilterValue, 54, 4, 0, 0, // Skip to: 384
154/* 380 */ MCD::OPC_Decode, 238, 2, 7, // Opcode: JUGE_ri_32
155/* 384 */ MCD::OPC_FilterValue, 55, 21, 0, 0, // Skip to: 410
156/* 389 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
157/* 392 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 401
158/* 397 */ MCD::OPC_Decode, 200, 2, 3, // Opcode: DIV_ri
159/* 401 */ MCD::OPC_FilterValue, 1, 200, 5, 0, // Skip to: 1886
160/* 406 */ MCD::OPC_Decode, 172, 3, 3, // Opcode: SDIV_ri
161/* 410 */ MCD::OPC_FilterValue, 60, 21, 0, 0, // Skip to: 436
162/* 415 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
163/* 418 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 427
164/* 423 */ MCD::OPC_Decode, 203, 2, 4, // Opcode: DIV_rr_32
165/* 427 */ MCD::OPC_FilterValue, 1, 174, 5, 0, // Skip to: 1886
166/* 432 */ MCD::OPC_Decode, 175, 3, 4, // Opcode: SDIV_rr_32
167/* 436 */ MCD::OPC_FilterValue, 61, 4, 0, 0, // Skip to: 445
168/* 441 */ MCD::OPC_Decode, 239, 2, 10, // Opcode: JUGE_rr
169/* 445 */ MCD::OPC_FilterValue, 62, 4, 0, 0, // Skip to: 454
170/* 450 */ MCD::OPC_Decode, 240, 2, 11, // Opcode: JUGE_rr_32
171/* 454 */ MCD::OPC_FilterValue, 63, 21, 0, 0, // Skip to: 480
172/* 459 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
173/* 462 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 471
174/* 467 */ MCD::OPC_Decode, 202, 2, 5, // Opcode: DIV_rr
175/* 471 */ MCD::OPC_FilterValue, 1, 130, 5, 0, // Skip to: 1886
176/* 476 */ MCD::OPC_Decode, 174, 3, 5, // Opcode: SDIV_rr
177/* 480 */ MCD::OPC_FilterValue, 64, 4, 0, 0, // Skip to: 489
178/* 485 */ MCD::OPC_Decode, 140, 3, 12, // Opcode: LD_IND_W
179/* 489 */ MCD::OPC_FilterValue, 68, 11, 0, 0, // Skip to: 505
180/* 494 */ MCD::OPC_CheckField, 32, 16, 0, 105, 5, 0, // Skip to: 1886
181/* 501 */ MCD::OPC_Decode, 168, 3, 0, // Opcode: OR_ri_32
182/* 505 */ MCD::OPC_FilterValue, 69, 4, 0, 0, // Skip to: 514
183/* 510 */ MCD::OPC_Decode, 217, 2, 6, // Opcode: JSET_ri
184/* 514 */ MCD::OPC_FilterValue, 70, 4, 0, 0, // Skip to: 523
185/* 519 */ MCD::OPC_Decode, 218, 2, 7, // Opcode: JSET_ri_32
186/* 523 */ MCD::OPC_FilterValue, 71, 11, 0, 0, // Skip to: 539
187/* 528 */ MCD::OPC_CheckField, 32, 16, 0, 71, 5, 0, // Skip to: 1886
188/* 535 */ MCD::OPC_Decode, 167, 3, 3, // Opcode: OR_ri
189/* 539 */ MCD::OPC_FilterValue, 72, 4, 0, 0, // Skip to: 548
190/* 544 */ MCD::OPC_Decode, 139, 3, 12, // Opcode: LD_IND_H
191/* 548 */ MCD::OPC_FilterValue, 76, 11, 0, 0, // Skip to: 564
192/* 553 */ MCD::OPC_CheckField, 32, 16, 0, 46, 5, 0, // Skip to: 1886
193/* 560 */ MCD::OPC_Decode, 170, 3, 4, // Opcode: OR_rr_32
194/* 564 */ MCD::OPC_FilterValue, 77, 4, 0, 0, // Skip to: 573
195/* 569 */ MCD::OPC_Decode, 219, 2, 10, // Opcode: JSET_rr
196/* 573 */ MCD::OPC_FilterValue, 78, 4, 0, 0, // Skip to: 582
197/* 578 */ MCD::OPC_Decode, 220, 2, 11, // Opcode: JSET_rr_32
198/* 582 */ MCD::OPC_FilterValue, 79, 11, 0, 0, // Skip to: 598
199/* 587 */ MCD::OPC_CheckField, 32, 16, 0, 12, 5, 0, // Skip to: 1886
200/* 594 */ MCD::OPC_Decode, 169, 3, 5, // Opcode: OR_rr
201/* 598 */ MCD::OPC_FilterValue, 80, 4, 0, 0, // Skip to: 607
202/* 603 */ MCD::OPC_Decode, 138, 3, 12, // Opcode: LD_IND_B
203/* 607 */ MCD::OPC_FilterValue, 84, 11, 0, 0, // Skip to: 623
204/* 612 */ MCD::OPC_CheckField, 32, 16, 0, 243, 4, 0, // Skip to: 1886
205/* 619 */ MCD::OPC_Decode, 185, 2, 0, // Opcode: AND_ri_32
206/* 623 */ MCD::OPC_FilterValue, 85, 4, 0, 0, // Skip to: 632
207/* 628 */ MCD::OPC_Decode, 213, 2, 6, // Opcode: JNE_ri
208/* 632 */ MCD::OPC_FilterValue, 86, 4, 0, 0, // Skip to: 641
209/* 637 */ MCD::OPC_Decode, 214, 2, 7, // Opcode: JNE_ri_32
210/* 641 */ MCD::OPC_FilterValue, 87, 11, 0, 0, // Skip to: 657
211/* 646 */ MCD::OPC_CheckField, 32, 16, 0, 209, 4, 0, // Skip to: 1886
212/* 653 */ MCD::OPC_Decode, 184, 2, 3, // Opcode: AND_ri
213/* 657 */ MCD::OPC_FilterValue, 92, 11, 0, 0, // Skip to: 673
214/* 662 */ MCD::OPC_CheckField, 32, 16, 0, 193, 4, 0, // Skip to: 1886
215/* 669 */ MCD::OPC_Decode, 187, 2, 4, // Opcode: AND_rr_32
216/* 673 */ MCD::OPC_FilterValue, 93, 4, 0, 0, // Skip to: 682
217/* 678 */ MCD::OPC_Decode, 215, 2, 10, // Opcode: JNE_rr
218/* 682 */ MCD::OPC_FilterValue, 94, 4, 0, 0, // Skip to: 691
219/* 687 */ MCD::OPC_Decode, 216, 2, 11, // Opcode: JNE_rr_32
220/* 691 */ MCD::OPC_FilterValue, 95, 11, 0, 0, // Skip to: 707
221/* 696 */ MCD::OPC_CheckField, 32, 16, 0, 159, 4, 0, // Skip to: 1886
222/* 703 */ MCD::OPC_Decode, 186, 2, 5, // Opcode: AND_rr
223/* 707 */ MCD::OPC_FilterValue, 97, 4, 0, 0, // Skip to: 716
224/* 712 */ MCD::OPC_Decode, 132, 3, 13, // Opcode: LDW
225/* 716 */ MCD::OPC_FilterValue, 98, 4, 0, 0, // Skip to: 725
226/* 721 */ MCD::OPC_Decode, 202, 3, 14, // Opcode: STW_imm
227/* 725 */ MCD::OPC_FilterValue, 99, 4, 0, 0, // Skip to: 734
228/* 730 */ MCD::OPC_Decode, 200, 3, 15, // Opcode: STW
229/* 734 */ MCD::OPC_FilterValue, 100, 11, 0, 0, // Skip to: 750
230/* 739 */ MCD::OPC_CheckField, 32, 16, 0, 116, 4, 0, // Skip to: 1886
231/* 746 */ MCD::OPC_Decode, 177, 3, 0, // Opcode: SLL_ri_32
232/* 750 */ MCD::OPC_FilterValue, 101, 4, 0, 0, // Skip to: 759
233/* 755 */ MCD::OPC_Decode, 225, 2, 6, // Opcode: JSGT_ri
234/* 759 */ MCD::OPC_FilterValue, 102, 4, 0, 0, // Skip to: 768
235/* 764 */ MCD::OPC_Decode, 226, 2, 7, // Opcode: JSGT_ri_32
236/* 768 */ MCD::OPC_FilterValue, 103, 11, 0, 0, // Skip to: 784
237/* 773 */ MCD::OPC_CheckField, 32, 16, 0, 82, 4, 0, // Skip to: 1886
238/* 780 */ MCD::OPC_Decode, 176, 3, 3, // Opcode: SLL_ri
239/* 784 */ MCD::OPC_FilterValue, 105, 4, 0, 0, // Skip to: 793
240/* 789 */ MCD::OPC_Decode, 129, 3, 13, // Opcode: LDH
241/* 793 */ MCD::OPC_FilterValue, 106, 4, 0, 0, // Skip to: 802
242/* 798 */ MCD::OPC_Decode, 199, 3, 14, // Opcode: STH_imm
243/* 802 */ MCD::OPC_FilterValue, 107, 4, 0, 0, // Skip to: 811
244/* 807 */ MCD::OPC_Decode, 197, 3, 15, // Opcode: STH
245/* 811 */ MCD::OPC_FilterValue, 108, 11, 0, 0, // Skip to: 827
246/* 816 */ MCD::OPC_CheckField, 32, 16, 0, 39, 4, 0, // Skip to: 1886
247/* 823 */ MCD::OPC_Decode, 179, 3, 4, // Opcode: SLL_rr_32
248/* 827 */ MCD::OPC_FilterValue, 109, 4, 0, 0, // Skip to: 836
249/* 832 */ MCD::OPC_Decode, 227, 2, 10, // Opcode: JSGT_rr
250/* 836 */ MCD::OPC_FilterValue, 110, 4, 0, 0, // Skip to: 845
251/* 841 */ MCD::OPC_Decode, 228, 2, 11, // Opcode: JSGT_rr_32
252/* 845 */ MCD::OPC_FilterValue, 111, 11, 0, 0, // Skip to: 861
253/* 850 */ MCD::OPC_CheckField, 32, 16, 0, 5, 4, 0, // Skip to: 1886
254/* 857 */ MCD::OPC_Decode, 178, 3, 5, // Opcode: SLL_rr
255/* 861 */ MCD::OPC_FilterValue, 113, 4, 0, 0, // Skip to: 870
256/* 866 */ MCD::OPC_Decode, 253, 2, 13, // Opcode: LDB
257/* 870 */ MCD::OPC_FilterValue, 114, 4, 0, 0, // Skip to: 879
258/* 875 */ MCD::OPC_Decode, 194, 3, 14, // Opcode: STB_imm
259/* 879 */ MCD::OPC_FilterValue, 115, 4, 0, 0, // Skip to: 888
260/* 884 */ MCD::OPC_Decode, 192, 3, 15, // Opcode: STB
261/* 888 */ MCD::OPC_FilterValue, 116, 11, 0, 0, // Skip to: 904
262/* 893 */ MCD::OPC_CheckField, 32, 16, 0, 218, 3, 0, // Skip to: 1886
263/* 900 */ MCD::OPC_Decode, 189, 3, 0, // Opcode: SRL_ri_32
264/* 904 */ MCD::OPC_FilterValue, 117, 4, 0, 0, // Skip to: 913
265/* 909 */ MCD::OPC_Decode, 221, 2, 6, // Opcode: JSGE_ri
266/* 913 */ MCD::OPC_FilterValue, 118, 4, 0, 0, // Skip to: 922
267/* 918 */ MCD::OPC_Decode, 222, 2, 7, // Opcode: JSGE_ri_32
268/* 922 */ MCD::OPC_FilterValue, 119, 11, 0, 0, // Skip to: 938
269/* 927 */ MCD::OPC_CheckField, 32, 16, 0, 184, 3, 0, // Skip to: 1886
270/* 934 */ MCD::OPC_Decode, 188, 3, 3, // Opcode: SRL_ri
271/* 938 */ MCD::OPC_FilterValue, 121, 4, 0, 0, // Skip to: 947
272/* 943 */ MCD::OPC_Decode, 128, 3, 13, // Opcode: LDD
273/* 947 */ MCD::OPC_FilterValue, 122, 4, 0, 0, // Skip to: 956
274/* 952 */ MCD::OPC_Decode, 196, 3, 14, // Opcode: STD_imm
275/* 956 */ MCD::OPC_FilterValue, 123, 4, 0, 0, // Skip to: 965
276/* 961 */ MCD::OPC_Decode, 195, 3, 15, // Opcode: STD
277/* 965 */ MCD::OPC_FilterValue, 124, 11, 0, 0, // Skip to: 981
278/* 970 */ MCD::OPC_CheckField, 32, 16, 0, 141, 3, 0, // Skip to: 1886
279/* 977 */ MCD::OPC_Decode, 191, 3, 4, // Opcode: SRL_rr_32
280/* 981 */ MCD::OPC_FilterValue, 125, 4, 0, 0, // Skip to: 990
281/* 986 */ MCD::OPC_Decode, 223, 2, 10, // Opcode: JSGE_rr
282/* 990 */ MCD::OPC_FilterValue, 126, 4, 0, 0, // Skip to: 999
283/* 995 */ MCD::OPC_Decode, 224, 2, 11, // Opcode: JSGE_rr_32
284/* 999 */ MCD::OPC_FilterValue, 127, 11, 0, 0, // Skip to: 1015
285/* 1004 */ MCD::OPC_CheckField, 32, 16, 0, 107, 3, 0, // Skip to: 1886
286/* 1011 */ MCD::OPC_Decode, 190, 3, 5, // Opcode: SRL_rr
287/* 1015 */ MCD::OPC_FilterValue, 129, 1, 4, 0, 0, // Skip to: 1025
288/* 1021 */ MCD::OPC_Decode, 134, 3, 13, // Opcode: LDWSX
289/* 1025 */ MCD::OPC_FilterValue, 132, 1, 4, 0, 0, // Skip to: 1035
290/* 1031 */ MCD::OPC_Decode, 164, 3, 16, // Opcode: NEG_32
291/* 1035 */ MCD::OPC_FilterValue, 133, 1, 4, 0, 0, // Skip to: 1045
292/* 1041 */ MCD::OPC_Decode, 204, 2, 2, // Opcode: JAL
293/* 1045 */ MCD::OPC_FilterValue, 135, 1, 4, 0, 0, // Skip to: 1055
294/* 1051 */ MCD::OPC_Decode, 165, 3, 17, // Opcode: NEG_64
295/* 1055 */ MCD::OPC_FilterValue, 137, 1, 4, 0, 0, // Skip to: 1065
296/* 1061 */ MCD::OPC_Decode, 131, 3, 13, // Opcode: LDHSX
297/* 1065 */ MCD::OPC_FilterValue, 141, 1, 4, 0, 0, // Skip to: 1075
298/* 1071 */ MCD::OPC_Decode, 205, 2, 18, // Opcode: JALX
299/* 1075 */ MCD::OPC_FilterValue, 145, 1, 4, 0, 0, // Skip to: 1085
300/* 1081 */ MCD::OPC_Decode, 255, 2, 13, // Opcode: LDBSX
301/* 1085 */ MCD::OPC_FilterValue, 148, 1, 21, 0, 0, // Skip to: 1112
302/* 1091 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
303/* 1094 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1103
304/* 1099 */ MCD::OPC_Decode, 147, 3, 0, // Opcode: MOD_ri_32
305/* 1103 */ MCD::OPC_FilterValue, 1, 10, 3, 0, // Skip to: 1886
306/* 1108 */ MCD::OPC_Decode, 181, 3, 0, // Opcode: SMOD_ri_32
307/* 1112 */ MCD::OPC_FilterValue, 149, 1, 11, 0, 0, // Skip to: 1129
308/* 1118 */ MCD::OPC_CheckField, 0, 32, 0, 249, 2, 0, // Skip to: 1886
309/* 1125 */ MCD::OPC_Decode, 171, 3, 19, // Opcode: RET
310/* 1129 */ MCD::OPC_FilterValue, 151, 1, 21, 0, 0, // Skip to: 1156
311/* 1135 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
312/* 1138 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1147
313/* 1143 */ MCD::OPC_Decode, 146, 3, 3, // Opcode: MOD_ri
314/* 1147 */ MCD::OPC_FilterValue, 1, 222, 2, 0, // Skip to: 1886
315/* 1152 */ MCD::OPC_Decode, 180, 3, 3, // Opcode: SMOD_ri
316/* 1156 */ MCD::OPC_FilterValue, 156, 1, 21, 0, 0, // Skip to: 1183
317/* 1162 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
318/* 1165 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1174
319/* 1170 */ MCD::OPC_Decode, 149, 3, 4, // Opcode: MOD_rr_32
320/* 1174 */ MCD::OPC_FilterValue, 1, 195, 2, 0, // Skip to: 1886
321/* 1179 */ MCD::OPC_Decode, 183, 3, 4, // Opcode: SMOD_rr_32
322/* 1183 */ MCD::OPC_FilterValue, 159, 1, 21, 0, 0, // Skip to: 1210
323/* 1189 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
324/* 1192 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1201
325/* 1197 */ MCD::OPC_Decode, 148, 3, 5, // Opcode: MOD_rr
326/* 1201 */ MCD::OPC_FilterValue, 1, 168, 2, 0, // Skip to: 1886
327/* 1206 */ MCD::OPC_Decode, 182, 3, 5, // Opcode: SMOD_rr
328/* 1210 */ MCD::OPC_FilterValue, 164, 1, 11, 0, 0, // Skip to: 1227
329/* 1216 */ MCD::OPC_CheckField, 32, 16, 0, 151, 2, 0, // Skip to: 1886
330/* 1223 */ MCD::OPC_Decode, 225, 3, 0, // Opcode: XOR_ri_32
331/* 1227 */ MCD::OPC_FilterValue, 165, 1, 4, 0, 0, // Skip to: 1237
332/* 1233 */ MCD::OPC_Decode, 249, 2, 6, // Opcode: JULT_ri
333/* 1237 */ MCD::OPC_FilterValue, 166, 1, 4, 0, 0, // Skip to: 1247
334/* 1243 */ MCD::OPC_Decode, 250, 2, 7, // Opcode: JULT_ri_32
335/* 1247 */ MCD::OPC_FilterValue, 167, 1, 11, 0, 0, // Skip to: 1264
336/* 1253 */ MCD::OPC_CheckField, 32, 16, 0, 114, 2, 0, // Skip to: 1886
337/* 1260 */ MCD::OPC_Decode, 224, 3, 3, // Opcode: XOR_ri
338/* 1264 */ MCD::OPC_FilterValue, 172, 1, 11, 0, 0, // Skip to: 1281
339/* 1270 */ MCD::OPC_CheckField, 32, 16, 0, 97, 2, 0, // Skip to: 1886
340/* 1277 */ MCD::OPC_Decode, 227, 3, 4, // Opcode: XOR_rr_32
341/* 1281 */ MCD::OPC_FilterValue, 173, 1, 4, 0, 0, // Skip to: 1291
342/* 1287 */ MCD::OPC_Decode, 251, 2, 10, // Opcode: JULT_rr
343/* 1291 */ MCD::OPC_FilterValue, 174, 1, 4, 0, 0, // Skip to: 1301
344/* 1297 */ MCD::OPC_Decode, 252, 2, 11, // Opcode: JULT_rr_32
345/* 1301 */ MCD::OPC_FilterValue, 175, 1, 11, 0, 0, // Skip to: 1318
346/* 1307 */ MCD::OPC_CheckField, 32, 16, 0, 60, 2, 0, // Skip to: 1886
347/* 1314 */ MCD::OPC_Decode, 226, 3, 5, // Opcode: XOR_rr
348/* 1318 */ MCD::OPC_FilterValue, 180, 1, 11, 0, 0, // Skip to: 1335
349/* 1324 */ MCD::OPC_CheckField, 32, 16, 0, 43, 2, 0, // Skip to: 1886
350/* 1331 */ MCD::OPC_Decode, 157, 3, 20, // Opcode: MOV_ri_32
351/* 1335 */ MCD::OPC_FilterValue, 181, 1, 4, 0, 0, // Skip to: 1345
352/* 1341 */ MCD::OPC_Decode, 245, 2, 6, // Opcode: JULE_ri
353/* 1345 */ MCD::OPC_FilterValue, 182, 1, 4, 0, 0, // Skip to: 1355
354/* 1351 */ MCD::OPC_Decode, 246, 2, 7, // Opcode: JULE_ri_32
355/* 1355 */ MCD::OPC_FilterValue, 183, 1, 11, 0, 0, // Skip to: 1372
356/* 1361 */ MCD::OPC_CheckField, 32, 16, 0, 6, 2, 0, // Skip to: 1886
357/* 1368 */ MCD::OPC_Decode, 156, 3, 8, // Opcode: MOV_ri
358/* 1372 */ MCD::OPC_FilterValue, 188, 1, 30, 0, 0, // Skip to: 1408
359/* 1378 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
360/* 1381 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1390
361/* 1386 */ MCD::OPC_Decode, 159, 3, 21, // Opcode: MOV_rr_32
362/* 1390 */ MCD::OPC_FilterValue, 8, 4, 0, 0, // Skip to: 1399
363/* 1395 */ MCD::OPC_Decode, 153, 3, 21, // Opcode: MOVSX_rr_32_8
364/* 1399 */ MCD::OPC_FilterValue, 16, 226, 1, 0, // Skip to: 1886
365/* 1404 */ MCD::OPC_Decode, 152, 3, 21, // Opcode: MOVSX_rr_32_16
366/* 1408 */ MCD::OPC_FilterValue, 189, 1, 4, 0, 0, // Skip to: 1418
367/* 1414 */ MCD::OPC_Decode, 247, 2, 10, // Opcode: JULE_rr
368/* 1418 */ MCD::OPC_FilterValue, 190, 1, 4, 0, 0, // Skip to: 1428
369/* 1424 */ MCD::OPC_Decode, 248, 2, 11, // Opcode: JULE_rr_32
370/* 1428 */ MCD::OPC_FilterValue, 191, 1, 48, 0, 0, // Skip to: 1482
371/* 1434 */ MCD::OPC_ExtractField, 32, 16, // Inst{47-32} ...
372/* 1437 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1446
373/* 1442 */ MCD::OPC_Decode, 158, 3, 22, // Opcode: MOV_rr
374/* 1446 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 1455
375/* 1451 */ MCD::OPC_Decode, 179, 2, 23, // Opcode: ADDR_SPACE_CAST
376/* 1455 */ MCD::OPC_FilterValue, 8, 4, 0, 0, // Skip to: 1464
377/* 1460 */ MCD::OPC_Decode, 154, 3, 22, // Opcode: MOVSX_rr_8
378/* 1464 */ MCD::OPC_FilterValue, 16, 4, 0, 0, // Skip to: 1473
379/* 1469 */ MCD::OPC_Decode, 150, 3, 22, // Opcode: MOVSX_rr_16
380/* 1473 */ MCD::OPC_FilterValue, 32, 152, 1, 0, // Skip to: 1886
381/* 1478 */ MCD::OPC_Decode, 151, 3, 22, // Opcode: MOVSX_rr_32
382/* 1482 */ MCD::OPC_FilterValue, 195, 1, 11, 0, 0, // Skip to: 1499
383/* 1488 */ MCD::OPC_CheckField, 4, 4, 0, 135, 1, 0, // Skip to: 1886
384/* 1495 */ MCD::OPC_Decode, 208, 3, 24, // Opcode: XADDW
385/* 1499 */ MCD::OPC_FilterValue, 196, 1, 11, 0, 0, // Skip to: 1516
386/* 1505 */ MCD::OPC_CheckField, 32, 16, 0, 118, 1, 0, // Skip to: 1886
387/* 1512 */ MCD::OPC_Decode, 185, 3, 0, // Opcode: SRA_ri_32
388/* 1516 */ MCD::OPC_FilterValue, 197, 1, 4, 0, 0, // Skip to: 1526
389/* 1522 */ MCD::OPC_Decode, 233, 2, 6, // Opcode: JSLT_ri
390/* 1526 */ MCD::OPC_FilterValue, 198, 1, 4, 0, 0, // Skip to: 1536
391/* 1532 */ MCD::OPC_Decode, 234, 2, 7, // Opcode: JSLT_ri_32
392/* 1536 */ MCD::OPC_FilterValue, 199, 1, 11, 0, 0, // Skip to: 1553
393/* 1542 */ MCD::OPC_CheckField, 32, 16, 0, 81, 1, 0, // Skip to: 1886
394/* 1549 */ MCD::OPC_Decode, 184, 3, 3, // Opcode: SRA_ri
395/* 1553 */ MCD::OPC_FilterValue, 204, 1, 11, 0, 0, // Skip to: 1570
396/* 1559 */ MCD::OPC_CheckField, 32, 16, 0, 64, 1, 0, // Skip to: 1886
397/* 1566 */ MCD::OPC_Decode, 187, 3, 4, // Opcode: SRA_rr_32
398/* 1570 */ MCD::OPC_FilterValue, 205, 1, 4, 0, 0, // Skip to: 1580
399/* 1576 */ MCD::OPC_Decode, 235, 2, 10, // Opcode: JSLT_rr
400/* 1580 */ MCD::OPC_FilterValue, 206, 1, 4, 0, 0, // Skip to: 1590
401/* 1586 */ MCD::OPC_Decode, 236, 2, 11, // Opcode: JSLT_rr_32
402/* 1590 */ MCD::OPC_FilterValue, 207, 1, 11, 0, 0, // Skip to: 1607
403/* 1596 */ MCD::OPC_CheckField, 32, 16, 0, 27, 1, 0, // Skip to: 1886
404/* 1603 */ MCD::OPC_Decode, 186, 3, 5, // Opcode: SRA_rr
405/* 1607 */ MCD::OPC_FilterValue, 212, 1, 30, 0, 0, // Skip to: 1643
406/* 1613 */ MCD::OPC_ExtractField, 0, 32, // Inst{31-0} ...
407/* 1616 */ MCD::OPC_FilterValue, 16, 4, 0, 0, // Skip to: 1625
408/* 1621 */ MCD::OPC_Decode, 143, 3, 17, // Opcode: LE16
409/* 1625 */ MCD::OPC_FilterValue, 32, 4, 0, 0, // Skip to: 1634
410/* 1630 */ MCD::OPC_Decode, 144, 3, 17, // Opcode: LE32
411/* 1634 */ MCD::OPC_FilterValue, 64, 247, 0, 0, // Skip to: 1886
412/* 1639 */ MCD::OPC_Decode, 145, 3, 17, // Opcode: LE64
413/* 1643 */ MCD::OPC_FilterValue, 213, 1, 4, 0, 0, // Skip to: 1653
414/* 1649 */ MCD::OPC_Decode, 229, 2, 6, // Opcode: JSLE_ri
415/* 1653 */ MCD::OPC_FilterValue, 214, 1, 4, 0, 0, // Skip to: 1663
416/* 1659 */ MCD::OPC_Decode, 230, 2, 7, // Opcode: JSLE_ri_32
417/* 1663 */ MCD::OPC_FilterValue, 215, 1, 30, 0, 0, // Skip to: 1699
418/* 1669 */ MCD::OPC_ExtractField, 0, 32, // Inst{31-0} ...
419/* 1672 */ MCD::OPC_FilterValue, 16, 4, 0, 0, // Skip to: 1681
420/* 1677 */ MCD::OPC_Decode, 191, 2, 17, // Opcode: BSWAP16
421/* 1681 */ MCD::OPC_FilterValue, 32, 4, 0, 0, // Skip to: 1690
422/* 1686 */ MCD::OPC_Decode, 192, 2, 17, // Opcode: BSWAP32
423/* 1690 */ MCD::OPC_FilterValue, 64, 191, 0, 0, // Skip to: 1886
424/* 1695 */ MCD::OPC_Decode, 193, 2, 17, // Opcode: BSWAP64
425/* 1699 */ MCD::OPC_FilterValue, 219, 1, 115, 0, 0, // Skip to: 1820
426/* 1705 */ MCD::OPC_ExtractField, 4, 4, // Inst{7-4} ...
427/* 1708 */ MCD::OPC_FilterValue, 0, 15, 0, 0, // Skip to: 1728
428/* 1713 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 1724
429/* 1720 */ MCD::OPC_Decode, 214, 3, 24, // Opcode: XFADDD
430/* 1724 */ MCD::OPC_Decode, 207, 3, 24, // Opcode: XADDD
431/* 1728 */ MCD::OPC_FilterValue, 4, 15, 0, 0, // Skip to: 1748
432/* 1733 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 1744
433/* 1740 */ MCD::OPC_Decode, 218, 3, 24, // Opcode: XFORD
434/* 1744 */ MCD::OPC_Decode, 222, 3, 24, // Opcode: XORD
435/* 1748 */ MCD::OPC_FilterValue, 5, 15, 0, 0, // Skip to: 1768
436/* 1753 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 1764
437/* 1760 */ MCD::OPC_Decode, 216, 3, 24, // Opcode: XFANDD
438/* 1764 */ MCD::OPC_Decode, 210, 3, 24, // Opcode: XANDD
439/* 1768 */ MCD::OPC_FilterValue, 10, 15, 0, 0, // Skip to: 1788
440/* 1773 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 1784
441/* 1780 */ MCD::OPC_Decode, 220, 3, 24, // Opcode: XFXORD
442/* 1784 */ MCD::OPC_Decode, 228, 3, 24, // Opcode: XXORD
443/* 1788 */ MCD::OPC_FilterValue, 14, 11, 0, 0, // Skip to: 1804
444/* 1793 */ MCD::OPC_CheckField, 0, 4, 1, 86, 0, 0, // Skip to: 1886
445/* 1800 */ MCD::OPC_Decode, 212, 3, 24, // Opcode: XCHGD
446/* 1804 */ MCD::OPC_FilterValue, 15, 77, 0, 0, // Skip to: 1886
447/* 1809 */ MCD::OPC_CheckField, 0, 4, 1, 70, 0, 0, // Skip to: 1886
448/* 1816 */ MCD::OPC_Decode, 194, 2, 25, // Opcode: CMPXCHGD
449/* 1820 */ MCD::OPC_FilterValue, 220, 1, 30, 0, 0, // Skip to: 1856
450/* 1826 */ MCD::OPC_ExtractField, 0, 32, // Inst{31-0} ...
451/* 1829 */ MCD::OPC_FilterValue, 16, 4, 0, 0, // Skip to: 1838
452/* 1834 */ MCD::OPC_Decode, 188, 2, 17, // Opcode: BE16
453/* 1838 */ MCD::OPC_FilterValue, 32, 4, 0, 0, // Skip to: 1847
454/* 1843 */ MCD::OPC_Decode, 189, 2, 17, // Opcode: BE32
455/* 1847 */ MCD::OPC_FilterValue, 64, 34, 0, 0, // Skip to: 1886
456/* 1852 */ MCD::OPC_Decode, 190, 2, 17, // Opcode: BE64
457/* 1856 */ MCD::OPC_FilterValue, 221, 1, 4, 0, 0, // Skip to: 1866
458/* 1862 */ MCD::OPC_Decode, 231, 2, 10, // Opcode: JSLE_rr
459/* 1866 */ MCD::OPC_FilterValue, 222, 1, 4, 0, 0, // Skip to: 1876
460/* 1872 */ MCD::OPC_Decode, 232, 2, 11, // Opcode: JSLE_rr_32
461/* 1876 */ MCD::OPC_FilterValue, 229, 1, 4, 0, 0, // Skip to: 1886
462/* 1882 */ MCD::OPC_Decode, 206, 2, 1, // Opcode: JCOND
463/* 1886 */ MCD::OPC_Fail,
464 0
465};
466
467static const uint8_t DecoderTableBPFALU3264[] = {
468/* 0 */ MCD::OPC_ExtractField, 56, 8, // Inst{63-56} ...
469/* 3 */ MCD::OPC_FilterValue, 97, 4, 0, 0, // Skip to: 12
470/* 8 */ MCD::OPC_Decode, 133, 3, 26, // Opcode: LDW32
471/* 12 */ MCD::OPC_FilterValue, 99, 4, 0, 0, // Skip to: 21
472/* 17 */ MCD::OPC_Decode, 201, 3, 27, // Opcode: STW32
473/* 21 */ MCD::OPC_FilterValue, 105, 4, 0, 0, // Skip to: 30
474/* 26 */ MCD::OPC_Decode, 130, 3, 26, // Opcode: LDH32
475/* 30 */ MCD::OPC_FilterValue, 107, 4, 0, 0, // Skip to: 39
476/* 35 */ MCD::OPC_Decode, 198, 3, 27, // Opcode: STH32
477/* 39 */ MCD::OPC_FilterValue, 113, 4, 0, 0, // Skip to: 48
478/* 44 */ MCD::OPC_Decode, 254, 2, 26, // Opcode: LDB32
479/* 48 */ MCD::OPC_FilterValue, 115, 4, 0, 0, // Skip to: 57
480/* 53 */ MCD::OPC_Decode, 193, 3, 27, // Opcode: STB32
481/* 57 */ MCD::OPC_FilterValue, 195, 1, 115, 0, 0, // Skip to: 178
482/* 63 */ MCD::OPC_ExtractField, 4, 4, // Inst{7-4} ...
483/* 66 */ MCD::OPC_FilterValue, 0, 15, 0, 0, // Skip to: 86
484/* 71 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 82
485/* 78 */ MCD::OPC_Decode, 215, 3, 28, // Opcode: XFADDW32
486/* 82 */ MCD::OPC_Decode, 209, 3, 28, // Opcode: XADDW32
487/* 86 */ MCD::OPC_FilterValue, 4, 15, 0, 0, // Skip to: 106
488/* 91 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 102
489/* 98 */ MCD::OPC_Decode, 219, 3, 28, // Opcode: XFORW32
490/* 102 */ MCD::OPC_Decode, 223, 3, 28, // Opcode: XORW32
491/* 106 */ MCD::OPC_FilterValue, 5, 15, 0, 0, // Skip to: 126
492/* 111 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 122
493/* 118 */ MCD::OPC_Decode, 217, 3, 28, // Opcode: XFANDW32
494/* 122 */ MCD::OPC_Decode, 211, 3, 28, // Opcode: XANDW32
495/* 126 */ MCD::OPC_FilterValue, 10, 15, 0, 0, // Skip to: 146
496/* 131 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 142
497/* 138 */ MCD::OPC_Decode, 221, 3, 28, // Opcode: XFXORW32
498/* 142 */ MCD::OPC_Decode, 229, 3, 28, // Opcode: XXORW32
499/* 146 */ MCD::OPC_FilterValue, 14, 11, 0, 0, // Skip to: 162
500/* 151 */ MCD::OPC_CheckField, 0, 4, 1, 20, 0, 0, // Skip to: 178
501/* 158 */ MCD::OPC_Decode, 213, 3, 28, // Opcode: XCHGW32
502/* 162 */ MCD::OPC_FilterValue, 15, 11, 0, 0, // Skip to: 178
503/* 167 */ MCD::OPC_CheckField, 0, 4, 1, 4, 0, 0, // Skip to: 178
504/* 174 */ MCD::OPC_Decode, 195, 2, 29, // Opcode: CMPXCHGW32
505/* 178 */ MCD::OPC_Fail,
506 0
507};
508
509static bool checkDecoderPredicate(unsigned Idx, const FeatureBitset &Bits) {
510 llvm_unreachable("Invalid index!");
511}
512
513template <typename InsnType>
514static DecodeStatus decodeToMCInst(DecodeStatus S, unsigned Idx, InsnType insn, MCInst &MI,
515 uint64_t Address, const MCDisassembler *Decoder, bool &DecodeComplete) {
516 DecodeComplete = true;
517 using TmpType = std::conditional_t<std::is_integral<InsnType>::value, InsnType, uint64_t>;
518 TmpType tmp;
519 switch (Idx) {
520 default: llvm_unreachable("Invalid index!");
521 case 0:
522 tmp = fieldFromInstruction(insn, 48, 4);
523 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
524 tmp = fieldFromInstruction(insn, 48, 4);
525 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
526 tmp = fieldFromInstruction(insn, 0, 32);
527 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
528 return S;
529 case 1:
530 tmp = fieldFromInstruction(insn, 32, 16);
531 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
532 return S;
533 case 2:
534 tmp = fieldFromInstruction(insn, 0, 32);
535 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
536 return S;
537 case 3:
538 tmp = fieldFromInstruction(insn, 48, 4);
539 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
540 tmp = fieldFromInstruction(insn, 48, 4);
541 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
542 tmp = fieldFromInstruction(insn, 0, 32);
543 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
544 return S;
545 case 4:
546 tmp = fieldFromInstruction(insn, 48, 4);
547 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
548 tmp = fieldFromInstruction(insn, 48, 4);
549 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
550 tmp = fieldFromInstruction(insn, 52, 4);
551 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
552 return S;
553 case 5:
554 tmp = fieldFromInstruction(insn, 48, 4);
555 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
556 tmp = fieldFromInstruction(insn, 48, 4);
557 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
558 tmp = fieldFromInstruction(insn, 52, 4);
559 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
560 return S;
561 case 6:
562 tmp = fieldFromInstruction(insn, 48, 4);
563 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
564 tmp = fieldFromInstruction(insn, 0, 32);
565 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
566 tmp = fieldFromInstruction(insn, 32, 16);
567 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
568 return S;
569 case 7:
570 tmp = fieldFromInstruction(insn, 48, 4);
571 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
572 tmp = fieldFromInstruction(insn, 0, 32);
573 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
574 tmp = fieldFromInstruction(insn, 32, 16);
575 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
576 return S;
577 case 8:
578 tmp = fieldFromInstruction(insn, 48, 4);
579 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
580 tmp = fieldFromInstruction(insn, 0, 32);
581 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
582 return S;
583 case 9:
584 tmp = fieldFromInstruction(insn, 48, 4);
585 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
586 tmp = fieldFromInstruction(insn, 52, 4);
587 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
588 tmp = fieldFromInstruction(insn, 0, 32);
589 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
590 return S;
591 case 10:
592 tmp = fieldFromInstruction(insn, 48, 4);
593 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
594 tmp = fieldFromInstruction(insn, 52, 4);
595 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
596 tmp = fieldFromInstruction(insn, 32, 16);
597 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
598 return S;
599 case 11:
600 tmp = fieldFromInstruction(insn, 48, 4);
601 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
602 tmp = fieldFromInstruction(insn, 52, 4);
603 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
604 tmp = fieldFromInstruction(insn, 32, 16);
605 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
606 return S;
607 case 12:
608 tmp = fieldFromInstruction(insn, 52, 4);
609 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
610 return S;
611 case 13:
612 tmp = fieldFromInstruction(insn, 48, 4);
613 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
614 tmp = 0x0;
615 insertBits(tmp, fieldFromInstruction(insn, 32, 16), 0, 16);
616 insertBits(tmp, fieldFromInstruction(insn, 52, 4), 16, 4);
617 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
618 return S;
619 case 14:
620 tmp = fieldFromInstruction(insn, 0, 32);
621 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
622 tmp = fieldFromInstruction(insn, 32, 20);
623 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
624 return S;
625 case 15:
626 tmp = fieldFromInstruction(insn, 52, 4);
627 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
628 tmp = fieldFromInstruction(insn, 32, 20);
629 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
630 return S;
631 case 16:
632 tmp = fieldFromInstruction(insn, 48, 4);
633 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
634 tmp = fieldFromInstruction(insn, 48, 4);
635 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
636 return S;
637 case 17:
638 tmp = fieldFromInstruction(insn, 48, 4);
639 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
640 tmp = fieldFromInstruction(insn, 48, 4);
641 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
642 return S;
643 case 18:
644 tmp = fieldFromInstruction(insn, 48, 4);
645 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
646 return S;
647 case 19:
648 return S;
649 case 20:
650 tmp = fieldFromInstruction(insn, 48, 4);
651 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
652 tmp = fieldFromInstruction(insn, 0, 32);
653 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
654 return S;
655 case 21:
656 tmp = fieldFromInstruction(insn, 48, 4);
657 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
658 tmp = fieldFromInstruction(insn, 52, 4);
659 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
660 return S;
661 case 22:
662 tmp = fieldFromInstruction(insn, 48, 4);
663 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
664 tmp = fieldFromInstruction(insn, 52, 4);
665 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
666 return S;
667 case 23:
668 tmp = fieldFromInstruction(insn, 48, 4);
669 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
670 tmp = fieldFromInstruction(insn, 52, 4);
671 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
672 tmp = fieldFromInstruction(insn, 16, 16);
673 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
674 tmp = fieldFromInstruction(insn, 0, 16);
675 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
676 return S;
677 case 24:
678 tmp = fieldFromInstruction(insn, 52, 4);
679 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
680 tmp = fieldFromInstruction(insn, 32, 20);
681 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
682 tmp = fieldFromInstruction(insn, 52, 4);
683 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
684 return S;
685 case 25:
686 tmp = fieldFromInstruction(insn, 32, 20);
687 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
688 tmp = fieldFromInstruction(insn, 52, 4);
689 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
690 return S;
691 case 26:
692 tmp = fieldFromInstruction(insn, 48, 4);
693 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
694 tmp = 0x0;
695 insertBits(tmp, fieldFromInstruction(insn, 32, 16), 0, 16);
696 insertBits(tmp, fieldFromInstruction(insn, 52, 4), 16, 4);
697 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
698 return S;
699 case 27:
700 tmp = fieldFromInstruction(insn, 52, 4);
701 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
702 tmp = fieldFromInstruction(insn, 32, 20);
703 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
704 return S;
705 case 28:
706 tmp = fieldFromInstruction(insn, 52, 4);
707 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
708 tmp = fieldFromInstruction(insn, 32, 20);
709 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
710 tmp = fieldFromInstruction(insn, 52, 4);
711 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
712 return S;
713 case 29:
714 tmp = fieldFromInstruction(insn, 32, 20);
715 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
716 tmp = fieldFromInstruction(insn, 52, 4);
717 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
718 return S;
719 }
720}
721
722template <typename InsnType>
723static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
724 InsnType insn, uint64_t Address,
725 const MCDisassembler *DisAsm,
726 const MCSubtargetInfo &STI) {
727 const FeatureBitset &Bits = STI.getFeatureBits();
728
729 const uint8_t *Ptr = DecodeTable;
730 uint64_t CurFieldValue = 0;
731 DecodeStatus S = MCDisassembler::Success;
732 while (true) {
733 ptrdiff_t Loc = Ptr - DecodeTable;
734 switch (*Ptr) {
735 default:
736 errs() << Loc << ": Unexpected decode table opcode!\n";
737 return MCDisassembler::Fail;
738 case MCD::OPC_ExtractField: {
739 // Decode the start value.
740 unsigned Start = decodeULEB128AndIncUnsafe(p&: ++Ptr);
741 unsigned Len = *Ptr++;
742 CurFieldValue = fieldFromInstruction(insn, Start, Len);
743 LLVM_DEBUG(dbgs() << Loc << ": OPC_ExtractField(" << Start << ", "
744 << Len << "): " << CurFieldValue << "\n");
745 break;
746 }
747 case MCD::OPC_FilterValue: {
748 // Decode the field value.
749 uint64_t Val = decodeULEB128AndIncUnsafe(p&: ++Ptr);
750 // NumToSkip is a plain 24-bit integer.
751 unsigned NumToSkip = *Ptr++;
752 NumToSkip |= (*Ptr++) << 8;
753 NumToSkip |= (*Ptr++) << 16;
754
755 // Perform the filter operation.
756 if (Val != CurFieldValue)
757 Ptr += NumToSkip;
758 LLVM_DEBUG(dbgs() << Loc << ": OPC_FilterValue(" << Val << ", " << NumToSkip
759 << "): " << ((Val != CurFieldValue) ? "FAIL:" : "PASS:")
760 << " continuing at " << (Ptr - DecodeTable) << "\n");
761
762 break;
763 }
764 case MCD::OPC_CheckField: {
765 // Decode the start value.
766 unsigned Start = decodeULEB128AndIncUnsafe(p&: ++Ptr);
767 unsigned Len = *Ptr;
768 uint64_t FieldValue = fieldFromInstruction(insn, Start, Len);
769 // Decode the field value.
770 unsigned PtrLen = 0;
771 uint64_t ExpectedValue = decodeULEB128(p: ++Ptr, n: &PtrLen);
772 Ptr += PtrLen;
773 // NumToSkip is a plain 24-bit integer.
774 unsigned NumToSkip = *Ptr++;
775 NumToSkip |= (*Ptr++) << 8;
776 NumToSkip |= (*Ptr++) << 16;
777
778 // If the actual and expected values don't match, skip.
779 if (ExpectedValue != FieldValue)
780 Ptr += NumToSkip;
781 LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckField(" << Start << ", "
782 << Len << ", " << ExpectedValue << ", " << NumToSkip
783 << "): FieldValue = " << FieldValue << ", ExpectedValue = "
784 << ExpectedValue << ": "
785 << ((ExpectedValue == FieldValue) ? "PASS\n" : "FAIL\n"));
786 break;
787 }
788 case MCD::OPC_CheckPredicate: {
789 // Decode the Predicate Index value.
790 unsigned PIdx = decodeULEB128AndIncUnsafe(p&: ++Ptr);
791 // NumToSkip is a plain 24-bit integer.
792 unsigned NumToSkip = *Ptr++;
793 NumToSkip |= (*Ptr++) << 8;
794 NumToSkip |= (*Ptr++) << 16;
795 // Check the predicate.
796 bool Pred;
797 if (!(Pred = checkDecoderPredicate(Idx: PIdx, Bits)))
798 Ptr += NumToSkip;
799 (void)Pred;
800 LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckPredicate(" << PIdx << "): "
801 << (Pred ? "PASS\n" : "FAIL\n"));
802
803 break;
804 }
805 case MCD::OPC_Decode: {
806 // Decode the Opcode value.
807 unsigned Opc = decodeULEB128AndIncUnsafe(p&: ++Ptr);
808 unsigned DecodeIdx = decodeULEB128AndIncUnsafe(p&: Ptr);
809
810 MI.clear();
811 MI.setOpcode(Opc);
812 bool DecodeComplete;
813 S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete);
814 assert(DecodeComplete);
815
816 LLVM_DEBUG(dbgs() << Loc << ": OPC_Decode: opcode " << Opc
817 << ", using decoder " << DecodeIdx << ": "
818 << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
819 return S;
820 }
821 case MCD::OPC_TryDecode: {
822 // Decode the Opcode value.
823 unsigned Opc = decodeULEB128AndIncUnsafe(p&: ++Ptr);
824 unsigned DecodeIdx = decodeULEB128AndIncUnsafe(p&: Ptr);
825 // NumToSkip is a plain 24-bit integer.
826 unsigned NumToSkip = *Ptr++;
827 NumToSkip |= (*Ptr++) << 8;
828 NumToSkip |= (*Ptr++) << 16;
829
830 // Perform the decode operation.
831 MCInst TmpMI;
832 TmpMI.setOpcode(Opc);
833 bool DecodeComplete;
834 S = decodeToMCInst(S, DecodeIdx, insn, TmpMI, Address, DisAsm, DecodeComplete);
835 LLVM_DEBUG(dbgs() << Loc << ": OPC_TryDecode: opcode " << Opc
836 << ", using decoder " << DecodeIdx << ": ");
837
838 if (DecodeComplete) {
839 // Decoding complete.
840 LLVM_DEBUG(dbgs() << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
841 MI = TmpMI;
842 return S;
843 } else {
844 assert(S == MCDisassembler::Fail);
845 // If the decoding was incomplete, skip.
846 Ptr += NumToSkip;
847 LLVM_DEBUG(dbgs() << "FAIL: continuing at " << (Ptr - DecodeTable) << "\n");
848 // Reset decode status. This also drops a SoftFail status that could be
849 // set before the decode attempt.
850 S = MCDisassembler::Success;
851 }
852 break;
853 }
854 case MCD::OPC_SoftFail: {
855 // Decode the mask values.
856 uint64_t PositiveMask = decodeULEB128AndIncUnsafe(p&: ++Ptr);
857 uint64_t NegativeMask = decodeULEB128AndIncUnsafe(p&: Ptr);
858 bool Fail = (insn & PositiveMask) != 0 || (~insn & NegativeMask) != 0;
859 if (Fail)
860 S = MCDisassembler::SoftFail;
861 LLVM_DEBUG(dbgs() << Loc << ": OPC_SoftFail: " << (Fail ? "FAIL\n" : "PASS\n"));
862 break;
863 }
864 case MCD::OPC_Fail: {
865 LLVM_DEBUG(dbgs() << Loc << ": OPC_Fail\n");
866 return MCDisassembler::Fail;
867 }
868 }
869 }
870 llvm_unreachable("bogosity detected in disassembler state machine!");
871}
872
873
874} // end namespace llvm
875