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 {
20
21// InsnBitWidth is essentially a type trait used by the decoder emitter to query
22// the supported bitwidth for a given type. But default, the value is 0, making
23// it an invalid type for use as `InsnType` when instantiating the decoder.
24// Individual targets are expected to provide specializations for these based
25// on their usage.
26template <typename T> constexpr uint32_t InsnBitWidth = 0;
27
28static const uint8_t DecoderTableBPF64[1331] = {
29 OPC_SwitchField, 56, 8, // 0: switch Inst[63:56] {
30 4, 8, // 3: case 0x4: {
31 OPC_CheckField, 32, 16, 0, // 5: check Inst[47:32] == 0x0
32 OPC_Decode, 227, 2, 0, // 9: decode to ADD_ri_32 using decoder 0
33 // 9: }
34 5, 4, // 13: case 0x5: {
35 OPC_Decode, 129, 3, 1, // 15: decode to JMP using decoder 1
36 // 15: }
37 6, 4, // 19: case 0x6: {
38 OPC_Decode, 130, 3, 2, // 21: decode to JMPL using decoder 2
39 // 21: }
40 7, 8, // 25: case 0x7: {
41 OPC_CheckField, 32, 16, 0, // 27: check Inst[47:32] == 0x0
42 OPC_Decode, 226, 2, 3, // 31: decode to ADD_ri using decoder 3
43 // 31: }
44 12, 8, // 35: case 0xc: {
45 OPC_CheckField, 32, 16, 0, // 37: check Inst[47:32] == 0x0
46 OPC_Decode, 229, 2, 4, // 41: decode to ADD_rr_32 using decoder 4
47 // 41: }
48 13, 4, // 45: case 0xd: {
49 OPC_Decode, 171, 3, 5, // 47: decode to JX using decoder 5
50 // 47: }
51 15, 8, // 51: case 0xf: {
52 OPC_CheckField, 32, 16, 0, // 53: check Inst[47:32] == 0x0
53 OPC_Decode, 228, 2, 6, // 57: decode to ADD_rr using decoder 6
54 // 57: }
55 20, 8, // 61: case 0x14: {
56 OPC_CheckField, 32, 16, 0, // 63: check Inst[47:32] == 0x0
57 OPC_Decode, 133, 4, 0, // 67: decode to SUB_ri_32 using decoder 0
58 // 67: }
59 21, 4, // 71: case 0x15: {
60 OPC_Decode, 253, 2, 7, // 73: decode to JEQ_ri using decoder 7
61 // 73: }
62 22, 4, // 77: case 0x16: {
63 OPC_Decode, 254, 2, 8, // 79: decode to JEQ_ri_32 using decoder 8
64 // 79: }
65 23, 8, // 83: case 0x17: {
66 OPC_CheckField, 32, 16, 0, // 85: check Inst[47:32] == 0x0
67 OPC_Decode, 132, 4, 3, // 89: decode to SUB_ri using decoder 3
68 // 89: }
69 24, 18, // 93: case 0x18: {
70 OPC_CheckField, 32, 16, 0, // 95: check Inst[47:32] == 0x0
71 OPC_Scope, 8, // 99: try {
72 OPC_CheckField, 52, 4, 0, // 101: check Inst[55:52] == 0x0
73 OPC_Decode, 192, 3, 9, // 105: decode to LD_imm64 using decoder 9
74 // 105: } else try {
75 OPC_Decode, 193, 3, 10, // 109: decode to LD_pseudo using decoder 10
76 // 109: }
77 // 109: }
78 28, 8, // 113: case 0x1c: {
79 OPC_CheckField, 32, 16, 0, // 115: check Inst[47:32] == 0x0
80 OPC_Decode, 135, 4, 4, // 119: decode to SUB_rr_32 using decoder 4
81 // 119: }
82 29, 4, // 123: case 0x1d: {
83 OPC_Decode, 255, 2, 11, // 125: decode to JEQ_rr using decoder 11
84 // 125: }
85 30, 4, // 129: case 0x1e: {
86 OPC_Decode, 128, 3, 12, // 131: decode to JEQ_rr_32 using decoder 12
87 // 131: }
88 31, 8, // 135: case 0x1f: {
89 OPC_CheckField, 32, 16, 0, // 137: check Inst[47:32] == 0x0
90 OPC_Decode, 134, 4, 6, // 141: decode to SUB_rr using decoder 6
91 // 141: }
92 32, 4, // 145: case 0x20: {
93 OPC_Decode, 188, 3, 2, // 147: decode to LD_ABS_W using decoder 2
94 // 147: }
95 36, 8, // 151: case 0x24: {
96 OPC_CheckField, 32, 16, 0, // 153: check Inst[47:32] == 0x0
97 OPC_Decode, 212, 3, 0, // 157: decode to MUL_ri_32 using decoder 0
98 // 157: }
99 37, 4, // 161: case 0x25: {
100 OPC_Decode, 159, 3, 7, // 163: decode to JUGT_ri using decoder 7
101 // 163: }
102 38, 4, // 167: case 0x26: {
103 OPC_Decode, 160, 3, 8, // 169: decode to JUGT_ri_32 using decoder 8
104 // 169: }
105 39, 21, // 173: case 0x27: {
106 OPC_SwitchField, 32, 16, // 175: switch Inst[47:32] {
107 0, 4, // 178: case 0x0: {
108 OPC_Decode, 211, 3, 3, // 180: decode to MUL_ri using decoder 3
109 // 180: }
110 1, 4, // 184: case 0x1: {
111 OPC_Decode, 136, 4, 3, // 186: decode to UHMUL_ri using decoder 3
112 // 186: }
113 2, 0, // 190: case 0x2: {
114 OPC_Decode, 227, 3, 3, // 192: decode to SHMUL_ri using decoder 3
115 // 192: }
116 // 192: } // switch Inst[47:32]
117 // 192: }
118 40, 4, // 196: case 0x28: {
119 OPC_Decode, 187, 3, 2, // 198: decode to LD_ABS_H using decoder 2
120 // 198: }
121 44, 8, // 202: case 0x2c: {
122 OPC_CheckField, 32, 16, 0, // 204: check Inst[47:32] == 0x0
123 OPC_Decode, 214, 3, 4, // 208: decode to MUL_rr_32 using decoder 4
124 // 208: }
125 45, 4, // 212: case 0x2d: {
126 OPC_Decode, 161, 3, 11, // 214: decode to JUGT_rr using decoder 11
127 // 214: }
128 46, 4, // 218: case 0x2e: {
129 OPC_Decode, 162, 3, 12, // 220: decode to JUGT_rr_32 using decoder 12
130 // 220: }
131 47, 21, // 224: case 0x2f: {
132 OPC_SwitchField, 32, 16, // 226: switch Inst[47:32] {
133 0, 4, // 229: case 0x0: {
134 OPC_Decode, 213, 3, 6, // 231: decode to MUL_rr using decoder 6
135 // 231: }
136 1, 4, // 235: case 0x1: {
137 OPC_Decode, 137, 4, 6, // 237: decode to UHMUL_rr using decoder 6
138 // 237: }
139 2, 0, // 241: case 0x2: {
140 OPC_Decode, 228, 3, 6, // 243: decode to SHMUL_rr using decoder 6
141 // 243: }
142 // 243: } // switch Inst[47:32]
143 // 243: }
144 48, 4, // 247: case 0x30: {
145 OPC_Decode, 186, 3, 2, // 249: decode to LD_ABS_B using decoder 2
146 // 249: }
147 52, 15, // 253: case 0x34: {
148 OPC_SwitchField, 32, 16, // 255: switch Inst[47:32] {
149 0, 4, // 258: case 0x0: {
150 OPC_Decode, 247, 2, 0, // 260: decode to DIV_ri_32 using decoder 0
151 // 260: }
152 1, 0, // 264: case 0x1: {
153 OPC_Decode, 224, 3, 0, // 266: decode to SDIV_ri_32 using decoder 0
154 // 266: }
155 // 266: } // switch Inst[47:32]
156 // 266: }
157 53, 4, // 270: case 0x35: {
158 OPC_Decode, 155, 3, 7, // 272: decode to JUGE_ri using decoder 7
159 // 272: }
160 54, 4, // 276: case 0x36: {
161 OPC_Decode, 156, 3, 8, // 278: decode to JUGE_ri_32 using decoder 8
162 // 278: }
163 55, 15, // 282: case 0x37: {
164 OPC_SwitchField, 32, 16, // 284: switch Inst[47:32] {
165 0, 4, // 287: case 0x0: {
166 OPC_Decode, 246, 2, 3, // 289: decode to DIV_ri using decoder 3
167 // 289: }
168 1, 0, // 293: case 0x1: {
169 OPC_Decode, 223, 3, 3, // 295: decode to SDIV_ri using decoder 3
170 // 295: }
171 // 295: } // switch Inst[47:32]
172 // 295: }
173 60, 15, // 299: case 0x3c: {
174 OPC_SwitchField, 32, 16, // 301: switch Inst[47:32] {
175 0, 4, // 304: case 0x0: {
176 OPC_Decode, 249, 2, 4, // 306: decode to DIV_rr_32 using decoder 4
177 // 306: }
178 1, 0, // 310: case 0x1: {
179 OPC_Decode, 226, 3, 4, // 312: decode to SDIV_rr_32 using decoder 4
180 // 312: }
181 // 312: } // switch Inst[47:32]
182 // 312: }
183 61, 4, // 316: case 0x3d: {
184 OPC_Decode, 157, 3, 11, // 318: decode to JUGE_rr using decoder 11
185 // 318: }
186 62, 4, // 322: case 0x3e: {
187 OPC_Decode, 158, 3, 12, // 324: decode to JUGE_rr_32 using decoder 12
188 // 324: }
189 63, 15, // 328: case 0x3f: {
190 OPC_SwitchField, 32, 16, // 330: switch Inst[47:32] {
191 0, 4, // 333: case 0x0: {
192 OPC_Decode, 248, 2, 6, // 335: decode to DIV_rr using decoder 6
193 // 335: }
194 1, 0, // 339: case 0x1: {
195 OPC_Decode, 225, 3, 6, // 341: decode to SDIV_rr using decoder 6
196 // 341: }
197 // 341: } // switch Inst[47:32]
198 // 341: }
199 64, 4, // 345: case 0x40: {
200 OPC_Decode, 191, 3, 13, // 347: decode to LD_IND_W using decoder 13
201 // 347: }
202 68, 8, // 351: case 0x44: {
203 OPC_CheckField, 32, 16, 0, // 353: check Inst[47:32] == 0x0
204 OPC_Decode, 219, 3, 0, // 357: decode to OR_ri_32 using decoder 0
205 // 357: }
206 69, 4, // 361: case 0x45: {
207 OPC_Decode, 135, 3, 7, // 363: decode to JSET_ri using decoder 7
208 // 363: }
209 70, 4, // 367: case 0x46: {
210 OPC_Decode, 136, 3, 8, // 369: decode to JSET_ri_32 using decoder 8
211 // 369: }
212 71, 8, // 373: case 0x47: {
213 OPC_CheckField, 32, 16, 0, // 375: check Inst[47:32] == 0x0
214 OPC_Decode, 218, 3, 3, // 379: decode to OR_ri using decoder 3
215 // 379: }
216 72, 4, // 383: case 0x48: {
217 OPC_Decode, 190, 3, 13, // 385: decode to LD_IND_H using decoder 13
218 // 385: }
219 76, 8, // 389: case 0x4c: {
220 OPC_CheckField, 32, 16, 0, // 391: check Inst[47:32] == 0x0
221 OPC_Decode, 221, 3, 4, // 395: decode to OR_rr_32 using decoder 4
222 // 395: }
223 77, 4, // 399: case 0x4d: {
224 OPC_Decode, 137, 3, 11, // 401: decode to JSET_rr using decoder 11
225 // 401: }
226 78, 4, // 405: case 0x4e: {
227 OPC_Decode, 138, 3, 12, // 407: decode to JSET_rr_32 using decoder 12
228 // 407: }
229 79, 8, // 411: case 0x4f: {
230 OPC_CheckField, 32, 16, 0, // 413: check Inst[47:32] == 0x0
231 OPC_Decode, 220, 3, 6, // 417: decode to OR_rr using decoder 6
232 // 417: }
233 80, 4, // 421: case 0x50: {
234 OPC_Decode, 189, 3, 13, // 423: decode to LD_IND_B using decoder 13
235 // 423: }
236 84, 8, // 427: case 0x54: {
237 OPC_CheckField, 32, 16, 0, // 429: check Inst[47:32] == 0x0
238 OPC_Decode, 231, 2, 0, // 433: decode to AND_ri_32 using decoder 0
239 // 433: }
240 85, 4, // 437: case 0x55: {
241 OPC_Decode, 131, 3, 7, // 439: decode to JNE_ri using decoder 7
242 // 439: }
243 86, 4, // 443: case 0x56: {
244 OPC_Decode, 132, 3, 8, // 445: decode to JNE_ri_32 using decoder 8
245 // 445: }
246 87, 8, // 449: case 0x57: {
247 OPC_CheckField, 32, 16, 0, // 451: check Inst[47:32] == 0x0
248 OPC_Decode, 230, 2, 3, // 455: decode to AND_ri using decoder 3
249 // 455: }
250 92, 8, // 459: case 0x5c: {
251 OPC_CheckField, 32, 16, 0, // 461: check Inst[47:32] == 0x0
252 OPC_Decode, 233, 2, 4, // 465: decode to AND_rr_32 using decoder 4
253 // 465: }
254 93, 4, // 469: case 0x5d: {
255 OPC_Decode, 133, 3, 11, // 471: decode to JNE_rr using decoder 11
256 // 471: }
257 94, 4, // 475: case 0x5e: {
258 OPC_Decode, 134, 3, 12, // 477: decode to JNE_rr_32 using decoder 12
259 // 477: }
260 95, 8, // 481: case 0x5f: {
261 OPC_CheckField, 32, 16, 0, // 483: check Inst[47:32] == 0x0
262 OPC_Decode, 232, 2, 6, // 487: decode to AND_rr using decoder 6
263 // 487: }
264 97, 4, // 491: case 0x61: {
265 OPC_Decode, 182, 3, 14, // 493: decode to LDW using decoder 14
266 // 493: }
267 98, 4, // 497: case 0x62: {
268 OPC_Decode, 131, 4, 15, // 499: decode to STW_imm using decoder 15
269 // 499: }
270 99, 4, // 503: case 0x63: {
271 OPC_Decode, 128, 4, 16, // 505: decode to STW using decoder 16
272 // 505: }
273 100, 8, // 509: case 0x64: {
274 OPC_CheckField, 32, 16, 0, // 511: check Inst[47:32] == 0x0
275 OPC_Decode, 230, 3, 0, // 515: decode to SLL_ri_32 using decoder 0
276 // 515: }
277 101, 4, // 519: case 0x65: {
278 OPC_Decode, 143, 3, 7, // 521: decode to JSGT_ri using decoder 7
279 // 521: }
280 102, 4, // 525: case 0x66: {
281 OPC_Decode, 144, 3, 8, // 527: decode to JSGT_ri_32 using decoder 8
282 // 527: }
283 103, 8, // 531: case 0x67: {
284 OPC_CheckField, 32, 16, 0, // 533: check Inst[47:32] == 0x0
285 OPC_Decode, 229, 3, 3, // 537: decode to SLL_ri using decoder 3
286 // 537: }
287 105, 4, // 541: case 0x69: {
288 OPC_Decode, 178, 3, 14, // 543: decode to LDH using decoder 14
289 // 543: }
290 106, 4, // 547: case 0x6a: {
291 OPC_Decode, 255, 3, 15, // 549: decode to STH_imm using decoder 15
292 // 549: }
293 107, 4, // 553: case 0x6b: {
294 OPC_Decode, 252, 3, 16, // 555: decode to STH using decoder 16
295 // 555: }
296 108, 8, // 559: case 0x6c: {
297 OPC_CheckField, 32, 16, 0, // 561: check Inst[47:32] == 0x0
298 OPC_Decode, 232, 3, 4, // 565: decode to SLL_rr_32 using decoder 4
299 // 565: }
300 109, 4, // 569: case 0x6d: {
301 OPC_Decode, 145, 3, 11, // 571: decode to JSGT_rr using decoder 11
302 // 571: }
303 110, 4, // 575: case 0x6e: {
304 OPC_Decode, 146, 3, 12, // 577: decode to JSGT_rr_32 using decoder 12
305 // 577: }
306 111, 8, // 581: case 0x6f: {
307 OPC_CheckField, 32, 16, 0, // 583: check Inst[47:32] == 0x0
308 OPC_Decode, 231, 3, 6, // 587: decode to SLL_rr using decoder 6
309 // 587: }
310 113, 4, // 591: case 0x71: {
311 OPC_Decode, 172, 3, 14, // 593: decode to LDB using decoder 14
312 // 593: }
313 114, 4, // 597: case 0x72: {
314 OPC_Decode, 248, 3, 15, // 599: decode to STB_imm using decoder 15
315 // 599: }
316 115, 4, // 603: case 0x73: {
317 OPC_Decode, 245, 3, 16, // 605: decode to STB using decoder 16
318 // 605: }
319 116, 8, // 609: case 0x74: {
320 OPC_CheckField, 32, 16, 0, // 611: check Inst[47:32] == 0x0
321 OPC_Decode, 242, 3, 0, // 615: decode to SRL_ri_32 using decoder 0
322 // 615: }
323 117, 4, // 619: case 0x75: {
324 OPC_Decode, 139, 3, 7, // 621: decode to JSGE_ri using decoder 7
325 // 621: }
326 118, 4, // 625: case 0x76: {
327 OPC_Decode, 140, 3, 8, // 627: decode to JSGE_ri_32 using decoder 8
328 // 627: }
329 119, 8, // 631: case 0x77: {
330 OPC_CheckField, 32, 16, 0, // 633: check Inst[47:32] == 0x0
331 OPC_Decode, 241, 3, 3, // 637: decode to SRL_ri using decoder 3
332 // 637: }
333 121, 4, // 641: case 0x79: {
334 OPC_Decode, 176, 3, 14, // 643: decode to LDD using decoder 14
335 // 643: }
336 122, 4, // 647: case 0x7a: {
337 OPC_Decode, 251, 3, 15, // 649: decode to STD_imm using decoder 15
338 // 649: }
339 123, 4, // 653: case 0x7b: {
340 OPC_Decode, 249, 3, 16, // 655: decode to STD using decoder 16
341 // 655: }
342 124, 8, // 659: case 0x7c: {
343 OPC_CheckField, 32, 16, 0, // 661: check Inst[47:32] == 0x0
344 OPC_Decode, 244, 3, 4, // 665: decode to SRL_rr_32 using decoder 4
345 // 665: }
346 125, 4, // 669: case 0x7d: {
347 OPC_Decode, 141, 3, 11, // 671: decode to JSGE_rr using decoder 11
348 // 671: }
349 126, 4, // 675: case 0x7e: {
350 OPC_Decode, 142, 3, 12, // 677: decode to JSGE_rr_32 using decoder 12
351 // 677: }
352 127, 8, // 681: case 0x7f: {
353 OPC_CheckField, 32, 16, 0, // 683: check Inst[47:32] == 0x0
354 OPC_Decode, 243, 3, 6, // 687: decode to SRL_rr using decoder 6
355 // 687: }
356 129, 1, 4, // 691: case 0x81: {
357 OPC_Decode, 185, 3, 14, // 694: decode to LDWSX using decoder 14
358 // 694: }
359 132, 1, 4, // 698: case 0x84: {
360 OPC_Decode, 215, 3, 17, // 701: decode to NEG_32 using decoder 17
361 // 701: }
362 133, 1, 4, // 705: case 0x85: {
363 OPC_Decode, 250, 2, 2, // 708: decode to JAL using decoder 2
364 // 708: }
365 135, 1, 4, // 712: case 0x87: {
366 OPC_Decode, 216, 3, 18, // 715: decode to NEG_64 using decoder 18
367 // 715: }
368 137, 1, 4, // 719: case 0x89: {
369 OPC_Decode, 181, 3, 14, // 722: decode to LDHSX using decoder 14
370 // 722: }
371 141, 1, 4, // 726: case 0x8d: {
372 OPC_Decode, 251, 2, 5, // 729: decode to JALX using decoder 5
373 // 729: }
374 145, 1, 4, // 733: case 0x91: {
375 OPC_Decode, 175, 3, 14, // 736: decode to LDBSX using decoder 14
376 // 736: }
377 148, 1, 15, // 740: case 0x94: {
378 OPC_SwitchField, 32, 16, // 743: switch Inst[47:32] {
379 0, 4, // 746: case 0x0: {
380 OPC_Decode, 198, 3, 0, // 748: decode to MOD_ri_32 using decoder 0
381 // 748: }
382 1, 0, // 752: case 0x1: {
383 OPC_Decode, 234, 3, 0, // 754: decode to SMOD_ri_32 using decoder 0
384 // 754: }
385 // 754: } // switch Inst[47:32]
386 // 754: }
387 149, 1, 23, // 758: case 0x95: {
388 OPC_SwitchField, 52, 4, // 761: switch Inst[55:52] {
389 0, 8, // 764: case 0x0: {
390 OPC_CheckField, 0, 32, 0, // 766: check Inst[31:0] == 0x0
391 OPC_Decode, 222, 3, 19, // 770: decode to RET using decoder 19
392 // 770: }
393 1, 0, // 774: case 0x1: {
394 OPC_CheckField, 0, 32, 0, // 776: check Inst[31:0] == 0x0
395 OPC_Decode, 138, 4, 19, // 780: decode to UNWIND_EXIT using decoder 19
396 // 780: }
397 // 780: } // switch Inst[55:52]
398 // 780: }
399 151, 1, 15, // 784: case 0x97: {
400 OPC_SwitchField, 32, 16, // 787: switch Inst[47:32] {
401 0, 4, // 790: case 0x0: {
402 OPC_Decode, 197, 3, 3, // 792: decode to MOD_ri using decoder 3
403 // 792: }
404 1, 0, // 796: case 0x1: {
405 OPC_Decode, 233, 3, 3, // 798: decode to SMOD_ri using decoder 3
406 // 798: }
407 // 798: } // switch Inst[47:32]
408 // 798: }
409 156, 1, 15, // 802: case 0x9c: {
410 OPC_SwitchField, 32, 16, // 805: switch Inst[47:32] {
411 0, 4, // 808: case 0x0: {
412 OPC_Decode, 200, 3, 4, // 810: decode to MOD_rr_32 using decoder 4
413 // 810: }
414 1, 0, // 814: case 0x1: {
415 OPC_Decode, 236, 3, 4, // 816: decode to SMOD_rr_32 using decoder 4
416 // 816: }
417 // 816: } // switch Inst[47:32]
418 // 816: }
419 159, 1, 15, // 820: case 0x9f: {
420 OPC_SwitchField, 32, 16, // 823: switch Inst[47:32] {
421 0, 4, // 826: case 0x0: {
422 OPC_Decode, 199, 3, 6, // 828: decode to MOD_rr using decoder 6
423 // 828: }
424 1, 0, // 832: case 0x1: {
425 OPC_Decode, 235, 3, 6, // 834: decode to SMOD_rr using decoder 6
426 // 834: }
427 // 834: } // switch Inst[47:32]
428 // 834: }
429 164, 1, 8, // 838: case 0xa4: {
430 OPC_CheckField, 32, 16, 0, // 841: check Inst[47:32] == 0x0
431 OPC_Decode, 158, 4, 0, // 845: decode to XOR_ri_32 using decoder 0
432 // 845: }
433 165, 1, 4, // 849: case 0xa5: {
434 OPC_Decode, 167, 3, 7, // 852: decode to JULT_ri using decoder 7
435 // 852: }
436 166, 1, 4, // 856: case 0xa6: {
437 OPC_Decode, 168, 3, 8, // 859: decode to JULT_ri_32 using decoder 8
438 // 859: }
439 167, 1, 8, // 863: case 0xa7: {
440 OPC_CheckField, 32, 16, 0, // 866: check Inst[47:32] == 0x0
441 OPC_Decode, 157, 4, 3, // 870: decode to XOR_ri using decoder 3
442 // 870: }
443 172, 1, 8, // 874: case 0xac: {
444 OPC_CheckField, 32, 16, 0, // 877: check Inst[47:32] == 0x0
445 OPC_Decode, 160, 4, 4, // 881: decode to XOR_rr_32 using decoder 4
446 // 881: }
447 173, 1, 4, // 885: case 0xad: {
448 OPC_Decode, 169, 3, 11, // 888: decode to JULT_rr using decoder 11
449 // 888: }
450 174, 1, 4, // 892: case 0xae: {
451 OPC_Decode, 170, 3, 12, // 895: decode to JULT_rr_32 using decoder 12
452 // 895: }
453 175, 1, 8, // 899: case 0xaf: {
454 OPC_CheckField, 32, 16, 0, // 902: check Inst[47:32] == 0x0
455 OPC_Decode, 159, 4, 6, // 906: decode to XOR_rr using decoder 6
456 // 906: }
457 180, 1, 8, // 910: case 0xb4: {
458 OPC_CheckField, 32, 16, 0, // 913: check Inst[47:32] == 0x0
459 OPC_Decode, 208, 3, 20, // 917: decode to MOV_ri_32 using decoder 20
460 // 917: }
461 181, 1, 4, // 921: case 0xb5: {
462 OPC_Decode, 163, 3, 7, // 924: decode to JULE_ri using decoder 7
463 // 924: }
464 182, 1, 4, // 928: case 0xb6: {
465 OPC_Decode, 164, 3, 8, // 931: decode to JULE_ri_32 using decoder 8
466 // 931: }
467 183, 1, 8, // 935: case 0xb7: {
468 OPC_CheckField, 32, 16, 0, // 938: check Inst[47:32] == 0x0
469 OPC_Decode, 207, 3, 9, // 942: decode to MOV_ri using decoder 9
470 // 942: }
471 188, 1, 21, // 946: case 0xbc: {
472 OPC_SwitchField, 32, 16, // 949: switch Inst[47:32] {
473 0, 4, // 952: case 0x0: {
474 OPC_Decode, 210, 3, 21, // 954: decode to MOV_rr_32 using decoder 21
475 // 954: }
476 8, 4, // 958: case 0x8: {
477 OPC_Decode, 204, 3, 21, // 960: decode to MOVSX_rr_32_8 using decoder 21
478 // 960: }
479 16, 0, // 964: case 0x10: {
480 OPC_Decode, 203, 3, 21, // 966: decode to MOVSX_rr_32_16 using decoder 21
481 // 966: }
482 // 966: } // switch Inst[47:32]
483 // 966: }
484 189, 1, 4, // 970: case 0xbd: {
485 OPC_Decode, 165, 3, 11, // 973: decode to JULE_rr using decoder 11
486 // 973: }
487 190, 1, 4, // 977: case 0xbe: {
488 OPC_Decode, 166, 3, 12, // 980: decode to JULE_rr_32 using decoder 12
489 // 980: }
490 191, 1, 33, // 984: case 0xbf: {
491 OPC_SwitchField, 32, 16, // 987: switch Inst[47:32] {
492 0, 4, // 990: case 0x0: {
493 OPC_Decode, 209, 3, 22, // 992: decode to MOV_rr using decoder 22
494 // 992: }
495 1, 4, // 996: case 0x1: {
496 OPC_Decode, 225, 2, 23, // 998: decode to ADDR_SPACE_CAST using decoder 23
497 // 998: }
498 8, 4, // 1002: case 0x8: {
499 OPC_Decode, 205, 3, 22, // 1004: decode to MOVSX_rr_8 using decoder 22
500 // 1004: }
501 16, 4, // 1008: case 0x10: {
502 OPC_Decode, 201, 3, 22, // 1010: decode to MOVSX_rr_16 using decoder 22
503 // 1010: }
504 32, 0, // 1014: case 0x20: {
505 OPC_Decode, 202, 3, 22, // 1016: decode to MOVSX_rr_32 using decoder 22
506 // 1016: }
507 // 1016: } // switch Inst[47:32]
508 // 1016: }
509 195, 1, 8, // 1020: case 0xc3: {
510 OPC_CheckField, 4, 4, 0, // 1023: check Inst[7:4] == 0x0
511 OPC_Decode, 141, 4, 24, // 1027: decode to XADDW using decoder 24
512 // 1027: }
513 196, 1, 8, // 1031: case 0xc4: {
514 OPC_CheckField, 32, 16, 0, // 1034: check Inst[47:32] == 0x0
515 OPC_Decode, 238, 3, 0, // 1038: decode to SRA_ri_32 using decoder 0
516 // 1038: }
517 197, 1, 4, // 1042: case 0xc5: {
518 OPC_Decode, 151, 3, 7, // 1045: decode to JSLT_ri using decoder 7
519 // 1045: }
520 198, 1, 4, // 1049: case 0xc6: {
521 OPC_Decode, 152, 3, 8, // 1052: decode to JSLT_ri_32 using decoder 8
522 // 1052: }
523 199, 1, 8, // 1056: case 0xc7: {
524 OPC_CheckField, 32, 16, 0, // 1059: check Inst[47:32] == 0x0
525 OPC_Decode, 237, 3, 3, // 1063: decode to SRA_ri using decoder 3
526 // 1063: }
527 204, 1, 8, // 1067: case 0xcc: {
528 OPC_CheckField, 32, 16, 0, // 1070: check Inst[47:32] == 0x0
529 OPC_Decode, 240, 3, 4, // 1074: decode to SRA_rr_32 using decoder 4
530 // 1074: }
531 205, 1, 4, // 1078: case 0xcd: {
532 OPC_Decode, 153, 3, 11, // 1081: decode to JSLT_rr using decoder 11
533 // 1081: }
534 206, 1, 4, // 1085: case 0xce: {
535 OPC_Decode, 154, 3, 12, // 1088: decode to JSLT_rr_32 using decoder 12
536 // 1088: }
537 207, 1, 8, // 1092: case 0xcf: {
538 OPC_CheckField, 32, 16, 0, // 1095: check Inst[47:32] == 0x0
539 OPC_Decode, 239, 3, 6, // 1099: decode to SRA_rr using decoder 6
540 // 1099: }
541 212, 1, 21, // 1103: case 0xd4: {
542 OPC_SwitchField, 0, 32, // 1106: switch Inst[31:0] {
543 16, 4, // 1109: case 0x10: {
544 OPC_Decode, 194, 3, 18, // 1111: decode to LE16 using decoder 18
545 // 1111: }
546 32, 4, // 1115: case 0x20: {
547 OPC_Decode, 195, 3, 18, // 1117: decode to LE32 using decoder 18
548 // 1117: }
549 64, 0, // 1121: case 0x40: {
550 OPC_Decode, 196, 3, 18, // 1123: decode to LE64 using decoder 18
551 // 1123: }
552 // 1123: } // switch Inst[31:0]
553 // 1123: }
554 213, 1, 4, // 1127: case 0xd5: {
555 OPC_Decode, 147, 3, 7, // 1130: decode to JSLE_ri using decoder 7
556 // 1130: }
557 214, 1, 4, // 1134: case 0xd6: {
558 OPC_Decode, 148, 3, 8, // 1137: decode to JSLE_ri_32 using decoder 8
559 // 1137: }
560 215, 1, 21, // 1141: case 0xd7: {
561 OPC_SwitchField, 0, 32, // 1144: switch Inst[31:0] {
562 16, 4, // 1147: case 0x10: {
563 OPC_Decode, 237, 2, 18, // 1149: decode to BSWAP16 using decoder 18
564 // 1149: }
565 32, 4, // 1153: case 0x20: {
566 OPC_Decode, 238, 2, 18, // 1155: decode to BSWAP32 using decoder 18
567 // 1155: }
568 64, 0, // 1159: case 0x40: {
569 OPC_Decode, 239, 2, 18, // 1161: decode to BSWAP64 using decoder 18
570 // 1161: }
571 // 1161: } // switch Inst[31:0]
572 // 1161: }
573 219, 1, 107, // 1165: case 0xdb: {
574 OPC_SwitchField, 4, 4, // 1168: switch Inst[7:4] {
575 0, 24, // 1171: case 0x0: {
576 OPC_Scope, 8, // 1173: try {
577 OPC_CheckField, 0, 4, 1, // 1175: check Inst[3:0] == 0x1
578 OPC_Decode, 147, 4, 24, // 1179: decode to XFADDD using decoder 24
579 OPC_Scope, 8, // 1183: } else try {
580 OPC_CheckField, 8, 1, 1, // 1185: check Inst[8] == 0x1
581 OPC_Decode, 177, 3, 14, // 1189: decode to LDDACQ using decoder 14
582 // 1189: } else try {
583 OPC_Decode, 140, 4, 24, // 1193: decode to XADDD using decoder 24
584 // 1193: }
585 // 1193: }
586 1, 8, // 1197: case 0x1: {
587 OPC_CheckField, 8, 1, 1, // 1199: check Inst[8] == 0x1
588 OPC_Decode, 250, 3, 16, // 1203: decode to STDREL using decoder 16
589 // 1203: }
590 4, 14, // 1207: case 0x4: {
591 OPC_Scope, 8, // 1209: try {
592 OPC_CheckField, 0, 4, 1, // 1211: check Inst[3:0] == 0x1
593 OPC_Decode, 151, 4, 24, // 1215: decode to XFORD using decoder 24
594 // 1215: } else try {
595 OPC_Decode, 155, 4, 24, // 1219: decode to XORD using decoder 24
596 // 1219: }
597 // 1219: }
598 5, 14, // 1223: case 0x5: {
599 OPC_Scope, 8, // 1225: try {
600 OPC_CheckField, 0, 4, 1, // 1227: check Inst[3:0] == 0x1
601 OPC_Decode, 149, 4, 24, // 1231: decode to XFANDD using decoder 24
602 // 1231: } else try {
603 OPC_Decode, 143, 4, 24, // 1235: decode to XANDD using decoder 24
604 // 1235: }
605 // 1235: }
606 10, 14, // 1239: case 0xa: {
607 OPC_Scope, 8, // 1241: try {
608 OPC_CheckField, 0, 4, 1, // 1243: check Inst[3:0] == 0x1
609 OPC_Decode, 153, 4, 24, // 1247: decode to XFXORD using decoder 24
610 // 1247: } else try {
611 OPC_Decode, 161, 4, 24, // 1251: decode to XXORD using decoder 24
612 // 1251: }
613 // 1251: }
614 14, 8, // 1255: case 0xe: {
615 OPC_CheckField, 0, 4, 1, // 1257: check Inst[3:0] == 0x1
616 OPC_Decode, 145, 4, 24, // 1261: decode to XCHGD using decoder 24
617 // 1261: }
618 15, 0, // 1265: case 0xf: {
619 OPC_CheckField, 0, 4, 1, // 1267: check Inst[3:0] == 0x1
620 OPC_Decode, 240, 2, 25, // 1271: decode to CMPXCHGD using decoder 25
621 // 1271: }
622 // 1271: } // switch Inst[7:4]
623 // 1271: }
624 220, 1, 21, // 1275: case 0xdc: {
625 OPC_SwitchField, 0, 32, // 1278: switch Inst[31:0] {
626 16, 4, // 1281: case 0x10: {
627 OPC_Decode, 234, 2, 18, // 1283: decode to BE16 using decoder 18
628 // 1283: }
629 32, 4, // 1287: case 0x20: {
630 OPC_Decode, 235, 2, 18, // 1289: decode to BE32 using decoder 18
631 // 1289: }
632 64, 0, // 1293: case 0x40: {
633 OPC_Decode, 236, 2, 18, // 1295: decode to BE64 using decoder 18
634 // 1295: }
635 // 1295: } // switch Inst[31:0]
636 // 1295: }
637 221, 1, 4, // 1299: case 0xdd: {
638 OPC_Decode, 149, 3, 11, // 1302: decode to JSLE_rr using decoder 11
639 // 1302: }
640 222, 1, 4, // 1306: case 0xde: {
641 OPC_Decode, 150, 3, 12, // 1309: decode to JSLE_rr_32 using decoder 12
642 // 1309: }
643 229, 1, 0, // 1313: case 0xe5: {
644 OPC_SwitchField, 52, 4, // 1316: switch Inst[55:52] {
645 0, 4, // 1319: case 0x0: {
646 OPC_Decode, 252, 2, 1, // 1321: decode to JCOND using decoder 1
647 // 1321: }
648 1, 0, // 1325: case 0x1: {
649 OPC_Decode, 139, 4, 1, // 1327: decode to UNWIND_GOTO using decoder 1
650 // 1327: }
651 // 1327: } // switch Inst[55:52]
652 // 1327: }
653 // 1327: } // switch Inst[63:56]
654};
655static const uint8_t DecoderTableBPFALU3264[185] = {
656 OPC_SwitchField, 56, 8, // 0: switch Inst[63:56] {
657 97, 4, // 3: case 0x61: {
658 OPC_Decode, 183, 3, 26, // 5: decode to LDW32 using decoder 26
659 // 5: }
660 99, 4, // 9: case 0x63: {
661 OPC_Decode, 129, 4, 27, // 11: decode to STW32 using decoder 27
662 // 11: }
663 105, 4, // 15: case 0x69: {
664 OPC_Decode, 179, 3, 26, // 17: decode to LDH32 using decoder 26
665 // 17: }
666 107, 4, // 21: case 0x6b: {
667 OPC_Decode, 253, 3, 27, // 23: decode to STH32 using decoder 27
668 // 23: }
669 113, 4, // 27: case 0x71: {
670 OPC_Decode, 173, 3, 26, // 29: decode to LDB32 using decoder 26
671 // 29: }
672 115, 4, // 33: case 0x73: {
673 OPC_Decode, 246, 3, 27, // 35: decode to STB32 using decoder 27
674 // 35: }
675 195, 1, 107, // 39: case 0xc3: {
676 OPC_SwitchField, 4, 4, // 42: switch Inst[7:4] {
677 0, 24, // 45: case 0x0: {
678 OPC_Scope, 8, // 47: try {
679 OPC_CheckField, 0, 4, 1, // 49: check Inst[3:0] == 0x1
680 OPC_Decode, 148, 4, 28, // 53: decode to XFADDW32 using decoder 28
681 OPC_Scope, 8, // 57: } else try {
682 OPC_CheckField, 8, 1, 1, // 59: check Inst[8] == 0x1
683 OPC_Decode, 184, 3, 26, // 63: decode to LDWACQ32 using decoder 26
684 // 63: } else try {
685 OPC_Decode, 142, 4, 28, // 67: decode to XADDW32 using decoder 28
686 // 67: }
687 // 67: }
688 1, 8, // 71: case 0x1: {
689 OPC_CheckField, 8, 1, 1, // 73: check Inst[8] == 0x1
690 OPC_Decode, 130, 4, 27, // 77: decode to STWREL32 using decoder 27
691 // 77: }
692 4, 14, // 81: case 0x4: {
693 OPC_Scope, 8, // 83: try {
694 OPC_CheckField, 0, 4, 1, // 85: check Inst[3:0] == 0x1
695 OPC_Decode, 152, 4, 28, // 89: decode to XFORW32 using decoder 28
696 // 89: } else try {
697 OPC_Decode, 156, 4, 28, // 93: decode to XORW32 using decoder 28
698 // 93: }
699 // 93: }
700 5, 14, // 97: case 0x5: {
701 OPC_Scope, 8, // 99: try {
702 OPC_CheckField, 0, 4, 1, // 101: check Inst[3:0] == 0x1
703 OPC_Decode, 150, 4, 28, // 105: decode to XFANDW32 using decoder 28
704 // 105: } else try {
705 OPC_Decode, 144, 4, 28, // 109: decode to XANDW32 using decoder 28
706 // 109: }
707 // 109: }
708 10, 14, // 113: case 0xa: {
709 OPC_Scope, 8, // 115: try {
710 OPC_CheckField, 0, 4, 1, // 117: check Inst[3:0] == 0x1
711 OPC_Decode, 154, 4, 28, // 121: decode to XFXORW32 using decoder 28
712 // 121: } else try {
713 OPC_Decode, 162, 4, 28, // 125: decode to XXORW32 using decoder 28
714 // 125: }
715 // 125: }
716 14, 8, // 129: case 0xe: {
717 OPC_CheckField, 0, 4, 1, // 131: check Inst[3:0] == 0x1
718 OPC_Decode, 146, 4, 28, // 135: decode to XCHGW32 using decoder 28
719 // 135: }
720 15, 0, // 139: case 0xf: {
721 OPC_CheckField, 0, 4, 1, // 141: check Inst[3:0] == 0x1
722 OPC_Decode, 241, 2, 29, // 145: decode to CMPXCHGW32 using decoder 29
723 // 145: }
724 // 145: } // switch Inst[7:4]
725 // 145: }
726 203, 1, 15, // 149: case 0xcb: {
727 OPC_SwitchField, 4, 5, // 152: switch Inst[8:4] {
728 16, 4, // 155: case 0x10: {
729 OPC_Decode, 180, 3, 26, // 157: decode to LDHACQ32 using decoder 26
730 // 157: }
731 17, 0, // 161: case 0x11: {
732 OPC_Decode, 254, 3, 27, // 163: decode to STHREL32 using decoder 27
733 // 163: }
734 // 163: } // switch Inst[8:4]
735 // 163: }
736 211, 1, 0, // 167: case 0xd3: {
737 OPC_SwitchField, 4, 5, // 170: switch Inst[8:4] {
738 16, 4, // 173: case 0x10: {
739 OPC_Decode, 174, 3, 26, // 175: decode to LDBACQ32 using decoder 26
740 // 175: }
741 17, 0, // 179: case 0x11: {
742 OPC_Decode, 247, 3, 27, // 181: decode to STBREL32 using decoder 27
743 // 181: }
744 // 181: } // switch Inst[8:4]
745 // 181: }
746 // 181: } // switch Inst[63:56]
747};
748// Handling 30 cases.
749template <typename InsnType>
750static DecodeStatus decodeToMCInst(unsigned Idx, DecodeStatus S, InsnType insn, MCInst &MI, uint64_t Address, const MCDisassembler *Decoder, bool &DecodeComplete) {
751 DecodeComplete = true;
752 using TmpType = std::conditional_t<std::is_integral<InsnType>::value, InsnType, uint64_t>;
753 TmpType tmp;
754 switch (Idx) {
755 default: llvm_unreachable("Invalid decoder index!");
756 case 0:
757 tmp = fieldFromInstruction(insn, 48, 4);
758 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
759 tmp = fieldFromInstruction(insn, 48, 4);
760 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
761 tmp = fieldFromInstruction(insn, 0, 32);
762 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
763 return S;
764 case 1:
765 tmp = fieldFromInstruction(insn, 32, 16);
766 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
767 return S;
768 case 2:
769 tmp = fieldFromInstruction(insn, 0, 32);
770 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
771 return S;
772 case 3:
773 tmp = fieldFromInstruction(insn, 48, 4);
774 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
775 tmp = fieldFromInstruction(insn, 48, 4);
776 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
777 tmp = fieldFromInstruction(insn, 0, 32);
778 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
779 return S;
780 case 4:
781 tmp = fieldFromInstruction(insn, 48, 4);
782 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
783 tmp = fieldFromInstruction(insn, 48, 4);
784 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
785 tmp = fieldFromInstruction(insn, 52, 4);
786 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
787 return S;
788 case 5:
789 tmp = fieldFromInstruction(insn, 48, 4);
790 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
791 return S;
792 case 6:
793 tmp = fieldFromInstruction(insn, 48, 4);
794 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
795 tmp = fieldFromInstruction(insn, 48, 4);
796 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
797 tmp = fieldFromInstruction(insn, 52, 4);
798 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
799 return S;
800 case 7:
801 tmp = fieldFromInstruction(insn, 48, 4);
802 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
803 tmp = fieldFromInstruction(insn, 0, 32);
804 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
805 tmp = fieldFromInstruction(insn, 32, 16);
806 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
807 return S;
808 case 8:
809 tmp = fieldFromInstruction(insn, 48, 4);
810 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
811 tmp = fieldFromInstruction(insn, 0, 32);
812 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
813 tmp = fieldFromInstruction(insn, 32, 16);
814 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
815 return S;
816 case 9:
817 tmp = fieldFromInstruction(insn, 48, 4);
818 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
819 tmp = fieldFromInstruction(insn, 0, 32);
820 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
821 return S;
822 case 10:
823 tmp = fieldFromInstruction(insn, 48, 4);
824 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
825 tmp = fieldFromInstruction(insn, 52, 4);
826 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
827 tmp = fieldFromInstruction(insn, 0, 32);
828 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
829 return S;
830 case 11:
831 tmp = fieldFromInstruction(insn, 48, 4);
832 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
833 tmp = fieldFromInstruction(insn, 52, 4);
834 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
835 tmp = fieldFromInstruction(insn, 32, 16);
836 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
837 return S;
838 case 12:
839 tmp = fieldFromInstruction(insn, 48, 4);
840 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
841 tmp = fieldFromInstruction(insn, 52, 4);
842 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
843 tmp = fieldFromInstruction(insn, 32, 16);
844 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
845 return S;
846 case 13:
847 tmp = fieldFromInstruction(insn, 52, 4);
848 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
849 return S;
850 case 14:
851 tmp = fieldFromInstruction(insn, 48, 4);
852 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
853 tmp = 0x0;
854 tmp |= fieldFromInstruction(insn, 32, 16);
855 tmp |= fieldFromInstruction(insn, 52, 4) << 16;
856 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
857 return S;
858 case 15:
859 tmp = fieldFromInstruction(insn, 0, 32);
860 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
861 tmp = fieldFromInstruction(insn, 32, 20);
862 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
863 return S;
864 case 16:
865 tmp = fieldFromInstruction(insn, 52, 4);
866 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
867 tmp = fieldFromInstruction(insn, 32, 20);
868 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
869 return S;
870 case 17:
871 tmp = fieldFromInstruction(insn, 48, 4);
872 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
873 tmp = fieldFromInstruction(insn, 48, 4);
874 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
875 return S;
876 case 18:
877 tmp = fieldFromInstruction(insn, 48, 4);
878 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
879 tmp = fieldFromInstruction(insn, 48, 4);
880 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
881 return S;
882 case 19:
883 return S;
884 case 20:
885 tmp = fieldFromInstruction(insn, 48, 4);
886 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
887 tmp = fieldFromInstruction(insn, 0, 32);
888 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
889 return S;
890 case 21:
891 tmp = fieldFromInstruction(insn, 48, 4);
892 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
893 tmp = fieldFromInstruction(insn, 52, 4);
894 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
895 return S;
896 case 22:
897 tmp = fieldFromInstruction(insn, 48, 4);
898 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
899 tmp = fieldFromInstruction(insn, 52, 4);
900 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
901 return S;
902 case 23:
903 tmp = fieldFromInstruction(insn, 48, 4);
904 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
905 tmp = fieldFromInstruction(insn, 52, 4);
906 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
907 tmp = fieldFromInstruction(insn, 16, 16);
908 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
909 tmp = fieldFromInstruction(insn, 0, 16);
910 MI.addOperand(Op: MCOperand::createImm(Val: tmp));
911 return S;
912 case 24:
913 tmp = fieldFromInstruction(insn, 52, 4);
914 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
915 tmp = fieldFromInstruction(insn, 32, 20);
916 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
917 tmp = fieldFromInstruction(insn, 52, 4);
918 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
919 return S;
920 case 25:
921 tmp = fieldFromInstruction(insn, 32, 20);
922 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
923 tmp = fieldFromInstruction(insn, 52, 4);
924 if (!Check(S, DecodeGPRRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
925 return S;
926 case 26:
927 tmp = fieldFromInstruction(insn, 48, 4);
928 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
929 tmp = 0x0;
930 tmp |= fieldFromInstruction(insn, 32, 16);
931 tmp |= fieldFromInstruction(insn, 52, 4) << 16;
932 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
933 return S;
934 case 27:
935 tmp = fieldFromInstruction(insn, 52, 4);
936 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
937 tmp = fieldFromInstruction(insn, 32, 20);
938 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
939 return S;
940 case 28:
941 tmp = fieldFromInstruction(insn, 52, 4);
942 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
943 tmp = fieldFromInstruction(insn, 32, 20);
944 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
945 tmp = fieldFromInstruction(insn, 52, 4);
946 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
947 return S;
948 case 29:
949 tmp = fieldFromInstruction(insn, 32, 20);
950 if (!Check(S, decodeMemoryOpValue(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
951 tmp = fieldFromInstruction(insn, 52, 4);
952 if (!Check(S, DecodeGPR32RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
953 return S;
954 }
955}
956
957template <typename InsnType>
958static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
959 InsnType insn, uint64_t Address,
960 const MCDisassembler *DisAsm,
961 const MCSubtargetInfo &STI) {
962 const uint8_t *Ptr = DecodeTable;
963
964 SmallVector<const uint8_t *, 8> ScopeStack;
965 DecodeStatus S = MCDisassembler::Success;
966 while (true) {
967 ptrdiff_t Loc = Ptr - DecodeTable;
968 const uint8_t DecoderOp = *Ptr++;
969 switch (DecoderOp) {
970 default:
971 errs() << Loc << ": Unexpected decode table opcode: "
972 << (int)DecoderOp << '\n';
973 return MCDisassembler::Fail;
974 case OPC_Scope: {
975 unsigned NumToSkip = decodeULEB128AndIncUnsafe(p&: Ptr);
976 const uint8_t *SkipTo = Ptr + NumToSkip;
977 ScopeStack.push_back(Elt: SkipTo);
978 LLVM_DEBUG(dbgs() << Loc << ": OPC_Scope(" << SkipTo - DecodeTable
979 << ")\n");
980 continue;
981 }
982 case OPC_SwitchField: {
983 // Decode the start value.
984 unsigned Start = decodeULEB128AndIncUnsafe(p&: Ptr);
985 unsigned Len = *Ptr++;
986 uint64_t FieldValue = fieldFromInstruction(insn, Start, Len);
987 uint64_t CaseValue;
988 unsigned CaseSize;
989 while (true) {
990 CaseValue = decodeULEB128AndIncUnsafe(p&: Ptr);
991 CaseSize = decodeULEB128AndIncUnsafe(p&: Ptr);
992 if (FieldValue <= CaseValue || !CaseSize)
993 break;
994 Ptr += CaseSize;
995 }
996 if (FieldValue == CaseValue) {
997 LLVM_DEBUG(dbgs() << Loc << ": OPC_SwitchField(" << Start << ", " << Len
998 << "): " << FieldValue << '\n');
999 continue;
1000 }
1001 break;
1002 }
1003 case OPC_CheckField: {
1004 // Decode the start value.
1005 unsigned Start = decodeULEB128AndIncUnsafe(p&: Ptr);
1006 unsigned Len = *Ptr;
1007 uint64_t FieldValue = fieldFromInstruction(insn, Start, Len);
1008 // Decode the field value.
1009 unsigned PtrLen = 0;
1010 uint64_t ExpectedValue = decodeULEB128(p: ++Ptr, n: &PtrLen);
1011 Ptr += PtrLen;
1012 bool Failed = ExpectedValue != FieldValue;
1013
1014 LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckField(" << Start << ", " << Len
1015 << ", " << ExpectedValue << "): FieldValue = "
1016 << FieldValue << ", ExpectedValue = " << ExpectedValue
1017 << ": " << (Failed ? "FAIL, " : "PASS\n"););
1018 if (!Failed)
1019 continue;
1020 break;
1021 }
1022 case OPC_Decode: {
1023 // Decode the Opcode value.
1024 unsigned Opc = decodeULEB128AndIncUnsafe(p&: Ptr);
1025 unsigned DecodeIdx = decodeULEB128AndIncUnsafe(p&: Ptr);
1026
1027 MI.clear();
1028 MI.setOpcode(Opc);
1029 bool DecodeComplete;
1030 S = decodeToMCInst(DecodeIdx, S, insn, MI, Address, DisAsm,
1031 DecodeComplete);
1032 LLVM_DEBUG(dbgs() << Loc << ": OPC_Decode: opcode " << Opc
1033 << ", using decoder " << DecodeIdx << ": "
1034 << (S ? "PASS, " : "FAIL, "));
1035
1036 if (DecodeComplete) {
1037 LLVM_DEBUG(dbgs() << "decoding complete\n");
1038 return S;
1039 }
1040 assert(S == MCDisassembler::Fail);
1041 // Reset decode status. This also drops a SoftFail status that could be
1042 // set before the decode attempt.
1043 S = MCDisassembler::Success;
1044 break;
1045 }
1046 }
1047 if (ScopeStack.empty()) {
1048 LLVM_DEBUG(dbgs() << "returning Fail\n");
1049 return MCDisassembler::Fail;
1050 }
1051 Ptr = ScopeStack.pop_back_val();
1052 LLVM_DEBUG(dbgs() << "continuing at " << Ptr - DecodeTable << '\n');
1053 }
1054 llvm_unreachable("bogosity detected in disassembler state machine!");
1055}
1056
1057
1058} // namespace
1059