1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Assembly Matcher Source Fragment *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: BPF.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10
11#ifdef GET_ASSEMBLER_HEADER
12#undef GET_ASSEMBLER_HEADER
13 // This should be included into the middle of the declaration of
14 // your subclasses implementation of MCTargetAsmParser.
15 FeatureBitset ComputeAvailableFeatures(const FeatureBitset &FB) const;
16 void convertToMCInst(unsigned Kind, MCInst &Inst, unsigned Opcode,
17 const OperandVector &Operands);
18 void convertToMapAndConstraints(unsigned Kind,
19 const OperandVector &Operands) override;
20 unsigned MatchInstructionImpl(const OperandVector &Operands,
21 MCInst &Inst,
22 uint64_t &ErrorInfo,
23 FeatureBitset &MissingFeatures,
24 bool matchingInlineAsm,
25 unsigned VariantID = 0);
26 unsigned MatchInstructionImpl(const OperandVector &Operands,
27 MCInst &Inst,
28 uint64_t &ErrorInfo,
29 bool matchingInlineAsm,
30 unsigned VariantID = 0) {
31 FeatureBitset MissingFeatures;
32 return MatchInstructionImpl(Operands, Inst, ErrorInfo, MissingFeatures,
33 matchingInlineAsm, VariantID);
34 }
35
36#endif // GET_ASSEMBLER_HEADER
37
38
39#ifdef GET_OPERAND_DIAGNOSTIC_TYPES
40#undef GET_OPERAND_DIAGNOSTIC_TYPES
41
42 Match_InvalidBrTarget,
43 Match_InvalidSImm16,
44 END_OPERAND_DIAGNOSTIC_TYPES
45#endif // GET_OPERAND_DIAGNOSTIC_TYPES
46
47
48#ifdef GET_REGISTER_MATCHER
49#undef GET_REGISTER_MATCHER
50
51// Bits for subtarget features that participate in instruction matching.
52enum SubtargetFeatureBits : uint8_t {
53};
54
55static MCRegister MatchRegisterName(StringRef Name) {
56 switch (Name.size()) {
57 default: break;
58 case 2: // 20 strings to match.
59 switch (Name[0]) {
60 default: break;
61 case 'r': // 10 strings to match.
62 switch (Name[1]) {
63 default: break;
64 case '0': // 1 string to match.
65 return BPF::R0; // "r0"
66 case '1': // 1 string to match.
67 return BPF::R1; // "r1"
68 case '2': // 1 string to match.
69 return BPF::R2; // "r2"
70 case '3': // 1 string to match.
71 return BPF::R3; // "r3"
72 case '4': // 1 string to match.
73 return BPF::R4; // "r4"
74 case '5': // 1 string to match.
75 return BPF::R5; // "r5"
76 case '6': // 1 string to match.
77 return BPF::R6; // "r6"
78 case '7': // 1 string to match.
79 return BPF::R7; // "r7"
80 case '8': // 1 string to match.
81 return BPF::R8; // "r8"
82 case '9': // 1 string to match.
83 return BPF::R9; // "r9"
84 }
85 break;
86 case 'w': // 10 strings to match.
87 switch (Name[1]) {
88 default: break;
89 case '0': // 1 string to match.
90 return BPF::W0; // "w0"
91 case '1': // 1 string to match.
92 return BPF::W1; // "w1"
93 case '2': // 1 string to match.
94 return BPF::W2; // "w2"
95 case '3': // 1 string to match.
96 return BPF::W3; // "w3"
97 case '4': // 1 string to match.
98 return BPF::W4; // "w4"
99 case '5': // 1 string to match.
100 return BPF::W5; // "w5"
101 case '6': // 1 string to match.
102 return BPF::W6; // "w6"
103 case '7': // 1 string to match.
104 return BPF::W7; // "w7"
105 case '8': // 1 string to match.
106 return BPF::W8; // "w8"
107 case '9': // 1 string to match.
108 return BPF::W9; // "w9"
109 }
110 break;
111 }
112 break;
113 case 3: // 4 strings to match.
114 switch (Name[0]) {
115 default: break;
116 case 'r': // 2 strings to match.
117 if (Name[1] != '1')
118 break;
119 switch (Name[2]) {
120 default: break;
121 case '0': // 1 string to match.
122 return BPF::R10; // "r10"
123 case '1': // 1 string to match.
124 return BPF::R11; // "r11"
125 }
126 break;
127 case 'w': // 2 strings to match.
128 if (Name[1] != '1')
129 break;
130 switch (Name[2]) {
131 default: break;
132 case '0': // 1 string to match.
133 return BPF::W10; // "w10"
134 case '1': // 1 string to match.
135 return BPF::W11; // "w11"
136 }
137 break;
138 }
139 break;
140 }
141 return BPF::NoRegister;
142}
143
144#endif // GET_REGISTER_MATCHER
145
146
147#ifdef GET_SUBTARGET_FEATURE_NAME
148#undef GET_SUBTARGET_FEATURE_NAME
149
150// User-level names for subtarget features that participate in
151// instruction matching.
152static const char *getSubtargetFeatureName(uint64_t Val) {
153 return "(unknown)";
154}
155
156#endif // GET_SUBTARGET_FEATURE_NAME
157
158
159#ifdef GET_MATCHER_IMPLEMENTATION
160#undef GET_MATCHER_IMPLEMENTATION
161
162enum {
163 Tie0_0_0,
164 Tie0_0_3,
165 Tie0_0_6,
166 Tie0_0_12,
167 Tie0_12_12,
168};
169
170static const uint8_t TiedAsmOperandTable[][3] = {
171 /* Tie0_0_0 */ { 0, 0, 0 },
172 /* Tie0_0_3 */ { 0, 0, 3 },
173 /* Tie0_0_6 */ { 0, 0, 6 },
174 /* Tie0_0_12 */ { 0, 0, 12 },
175 /* Tie0_12_12 */ { 0, 12, 12 },
176};
177
178namespace {
179enum OperatorConversionKind {
180 CVT_Done,
181 CVT_Reg,
182 CVT_Tied,
183 CVT_95_Reg,
184 CVT_95_addImmOperands,
185 CVT_imm_95_0,
186 CVT_NUM_CONVERTERS
187};
188
189enum InstructionConversionKind {
190 Convert__Reg1_0__Reg1_2,
191 Convert__Reg1_0__Imm1_2,
192 Convert__Reg1_0__Tie0_0_0__Reg1_3,
193 Convert__Reg1_0__Tie0_0_0__Imm1_3,
194 Convert__Reg1_0__Tie0_0_3,
195 Convert__Reg1_0__Tie0_0_0__Reg1_4,
196 Convert__Reg1_0__Tie0_0_0__Imm1_4,
197 Convert__Reg1_0__Reg1_5,
198 Convert__Reg1_0__Tie0_0_0__Reg1_5,
199 Convert__Reg1_0__Tie0_0_0__Imm1_5,
200 Convert__Reg1_0__Reg1_4__Imm1_5__Imm1_6,
201 Convert__Reg1_0__Reg1_4__SImm161_5__Tie0_0_6,
202 Convert__Reg1_0__Reg1_8__SImm161_9,
203 Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12,
204 Convert__Reg1_10__Reg1_6__SImm161_7,
205 Convert__Imm1_10__Reg1_6__SImm161_7,
206 Convert__Imm1_1,
207 Convert__Reg1_1,
208 Convert_NoOperands,
209 Convert__BrTarget1_1,
210 Convert__Reg1_1__Reg1_3__BrTarget1_5,
211 Convert__Reg1_1__Imm1_3__BrTarget1_5,
212 Convert__Reg1_1__Reg1_4__BrTarget1_6,
213 Convert__Reg1_1__Imm1_4__BrTarget1_6,
214 Convert__Reg1_1__Reg1_5__BrTarget1_7,
215 Convert__Reg1_1__Imm1_5__BrTarget1_7,
216 Convert__Reg1_1__Imm1_2__Imm1_3,
217 Convert__Reg1_1__Reg1_2__SImm161_3,
218 Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12,
219 Convert__Reg1_4__SImm161_5__Reg1_7,
220 Convert__imm_95_0__Reg1_9,
221 Convert__imm_95_0__Imm1_9,
222 CVT_NUM_SIGNATURES
223};
224
225} // end anonymous namespace
226
227static const uint8_t ConversionTable[CVT_NUM_SIGNATURES][9] = {
228 // Convert__Reg1_0__Reg1_2
229 { CVT_95_Reg, 0, CVT_95_Reg, 2, CVT_Done },
230 // Convert__Reg1_0__Imm1_2
231 { CVT_95_Reg, 0, CVT_95_addImmOperands, 2, CVT_Done },
232 // Convert__Reg1_0__Tie0_0_0__Reg1_3
233 { CVT_95_Reg, 0, CVT_Tied, Tie0_0_0, CVT_95_Reg, 3, CVT_Done },
234 // Convert__Reg1_0__Tie0_0_0__Imm1_3
235 { CVT_95_Reg, 0, CVT_Tied, Tie0_0_0, CVT_95_addImmOperands, 3, CVT_Done },
236 // Convert__Reg1_0__Tie0_0_3
237 { CVT_95_Reg, 0, CVT_Tied, Tie0_0_3, CVT_Done },
238 // Convert__Reg1_0__Tie0_0_0__Reg1_4
239 { CVT_95_Reg, 0, CVT_Tied, Tie0_0_0, CVT_95_Reg, 4, CVT_Done },
240 // Convert__Reg1_0__Tie0_0_0__Imm1_4
241 { CVT_95_Reg, 0, CVT_Tied, Tie0_0_0, CVT_95_addImmOperands, 4, CVT_Done },
242 // Convert__Reg1_0__Reg1_5
243 { CVT_95_Reg, 0, CVT_95_Reg, 5, CVT_Done },
244 // Convert__Reg1_0__Tie0_0_0__Reg1_5
245 { CVT_95_Reg, 0, CVT_Tied, Tie0_0_0, CVT_95_Reg, 5, CVT_Done },
246 // Convert__Reg1_0__Tie0_0_0__Imm1_5
247 { CVT_95_Reg, 0, CVT_Tied, Tie0_0_0, CVT_95_addImmOperands, 5, CVT_Done },
248 // Convert__Reg1_0__Reg1_4__Imm1_5__Imm1_6
249 { CVT_95_Reg, 0, CVT_95_Reg, 4, CVT_95_addImmOperands, 5, CVT_95_addImmOperands, 6, CVT_Done },
250 // Convert__Reg1_0__Reg1_4__SImm161_5__Tie0_0_6
251 { CVT_95_Reg, 0, CVT_95_Reg, 4, CVT_95_addImmOperands, 5, CVT_Tied, Tie0_0_6, CVT_Done },
252 // Convert__Reg1_0__Reg1_8__SImm161_9
253 { CVT_95_Reg, 0, CVT_95_Reg, 8, CVT_95_addImmOperands, 9, CVT_Done },
254 // Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12
255 { CVT_95_Reg, 0, CVT_95_Reg, 9, CVT_95_addImmOperands, 10, CVT_Tied, Tie0_0_12, CVT_Done },
256 // Convert__Reg1_10__Reg1_6__SImm161_7
257 { CVT_95_Reg, 10, CVT_95_Reg, 6, CVT_95_addImmOperands, 7, CVT_Done },
258 // Convert__Imm1_10__Reg1_6__SImm161_7
259 { CVT_95_addImmOperands, 10, CVT_95_Reg, 6, CVT_95_addImmOperands, 7, CVT_Done },
260 // Convert__Imm1_1
261 { CVT_95_addImmOperands, 1, CVT_Done },
262 // Convert__Reg1_1
263 { CVT_95_Reg, 1, CVT_Done },
264 // Convert_NoOperands
265 { CVT_Done },
266 // Convert__BrTarget1_1
267 { CVT_95_addImmOperands, 1, CVT_Done },
268 // Convert__Reg1_1__Reg1_3__BrTarget1_5
269 { CVT_95_Reg, 1, CVT_95_Reg, 3, CVT_95_addImmOperands, 5, CVT_Done },
270 // Convert__Reg1_1__Imm1_3__BrTarget1_5
271 { CVT_95_Reg, 1, CVT_95_addImmOperands, 3, CVT_95_addImmOperands, 5, CVT_Done },
272 // Convert__Reg1_1__Reg1_4__BrTarget1_6
273 { CVT_95_Reg, 1, CVT_95_Reg, 4, CVT_95_addImmOperands, 6, CVT_Done },
274 // Convert__Reg1_1__Imm1_4__BrTarget1_6
275 { CVT_95_Reg, 1, CVT_95_addImmOperands, 4, CVT_95_addImmOperands, 6, CVT_Done },
276 // Convert__Reg1_1__Reg1_5__BrTarget1_7
277 { CVT_95_Reg, 1, CVT_95_Reg, 5, CVT_95_addImmOperands, 7, CVT_Done },
278 // Convert__Reg1_1__Imm1_5__BrTarget1_7
279 { CVT_95_Reg, 1, CVT_95_addImmOperands, 5, CVT_95_addImmOperands, 7, CVT_Done },
280 // Convert__Reg1_1__Imm1_2__Imm1_3
281 { CVT_95_Reg, 1, CVT_95_addImmOperands, 2, CVT_95_addImmOperands, 3, CVT_Done },
282 // Convert__Reg1_1__Reg1_2__SImm161_3
283 { CVT_95_Reg, 1, CVT_95_Reg, 2, CVT_95_addImmOperands, 3, CVT_Done },
284 // Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12
285 { CVT_95_Reg, 12, CVT_95_Reg, 7, CVT_95_addImmOperands, 8, CVT_Tied, Tie0_12_12, CVT_Done },
286 // Convert__Reg1_4__SImm161_5__Reg1_7
287 { CVT_95_Reg, 4, CVT_95_addImmOperands, 5, CVT_95_Reg, 7, CVT_Done },
288 // Convert__imm_95_0__Reg1_9
289 { CVT_imm_95_0, 0, CVT_95_Reg, 9, CVT_Done },
290 // Convert__imm_95_0__Imm1_9
291 { CVT_imm_95_0, 0, CVT_95_addImmOperands, 9, CVT_Done },
292};
293
294void BPFAsmParser::
295convertToMCInst(unsigned Kind, MCInst &Inst, unsigned Opcode,
296 const OperandVector &Operands) {
297 assert(Kind < CVT_NUM_SIGNATURES && "Invalid signature!");
298 const uint8_t *Converter = ConversionTable[Kind];
299 Inst.setOpcode(Opcode);
300 for (const uint8_t *p = Converter; *p; p += 2) {
301 unsigned OpIdx = *(p + 1);
302 switch (*p) {
303 default: llvm_unreachable("invalid conversion entry!");
304 case CVT_Reg:
305 static_cast<BPFOperand &>(*Operands[OpIdx]).addRegOperands(Inst, 1);
306 break;
307 case CVT_Tied: {
308 assert(*(p + 1) < (size_t)(std::end(TiedAsmOperandTable) -
309 std::begin(TiedAsmOperandTable)) &&
310 "Tied operand not found");
311 unsigned TiedResOpnd = TiedAsmOperandTable[*(p + 1)][0];
312 if (TiedResOpnd != (uint8_t)-1)
313 Inst.addOperand(Inst.getOperand(TiedResOpnd));
314 break;
315 }
316 case CVT_95_Reg:
317 static_cast<BPFOperand &>(*Operands[OpIdx]).addRegOperands(Inst, 1);
318 break;
319 case CVT_95_addImmOperands:
320 static_cast<BPFOperand &>(*Operands[OpIdx]).addImmOperands(Inst, 1);
321 break;
322 case CVT_imm_95_0:
323 Inst.addOperand(MCOperand::createImm(0));
324 break;
325 }
326 }
327}
328
329void BPFAsmParser::
330convertToMapAndConstraints(unsigned Kind,
331 const OperandVector &Operands) {
332 assert(Kind < CVT_NUM_SIGNATURES && "Invalid signature!");
333 unsigned NumMCOperands = 0;
334 const uint8_t *Converter = ConversionTable[Kind];
335 for (const uint8_t *p = Converter; *p; p += 2) {
336 switch (*p) {
337 default: llvm_unreachable("invalid conversion entry!");
338 case CVT_Reg:
339 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
340 Operands[*(p + 1)]->setConstraint("r");
341 ++NumMCOperands;
342 break;
343 case CVT_Tied:
344 ++NumMCOperands;
345 break;
346 case CVT_95_Reg:
347 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
348 Operands[*(p + 1)]->setConstraint("r");
349 NumMCOperands += 1;
350 break;
351 case CVT_95_addImmOperands:
352 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
353 Operands[*(p + 1)]->setConstraint("m");
354 NumMCOperands += 1;
355 break;
356 case CVT_imm_95_0:
357 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
358 Operands[*(p + 1)]->setConstraint("");
359 ++NumMCOperands;
360 break;
361 }
362 }
363}
364
365namespace {
366
367/// MatchClassKind - The kinds of classes which participate in
368/// instruction matching.
369enum MatchClassKind {
370 InvalidMatchClass = 0,
371 OptionalMatchClass = 1,
372 MCK__EXCLAIM_, // '!'
373 MCK__PCT_, // '%'
374 MCK__38_, // '&'
375 MCK__40_, // '('
376 MCK__41_, // ')'
377 MCK__STAR_, // '*'
378 MCK__43_, // '+'
379 MCK__MINUS_, // '-'
380 MCK__47_, // '/'
381 MCK__LT_, // '<'
382 MCK__61_, // '='
383 MCK__GT_, // '>'
384 MCK__91_, // '['
385 MCK__93_, // ']'
386 MCK__94_, // '^'
387 MCK_addr_95_space_95_cast, // 'addr_space_cast'
388 MCK_atomic_95_fetch_95_add, // 'atomic_fetch_add'
389 MCK_atomic_95_fetch_95_and, // 'atomic_fetch_and'
390 MCK_atomic_95_fetch_95_or, // 'atomic_fetch_or'
391 MCK_atomic_95_fetch_95_xor, // 'atomic_fetch_xor'
392 MCK_be16, // 'be16'
393 MCK_be32, // 'be32'
394 MCK_be64, // 'be64'
395 MCK_bswap16, // 'bswap16'
396 MCK_bswap32, // 'bswap32'
397 MCK_bswap64, // 'bswap64'
398 MCK_call, // 'call'
399 MCK_callx, // 'callx'
400 MCK_cmpxchg32_95_32, // 'cmpxchg32_32'
401 MCK_cmpxchg_95_64, // 'cmpxchg_64'
402 MCK_exit, // 'exit'
403 MCK_goto, // 'goto'
404 MCK_gotol, // 'gotol'
405 MCK_if, // 'if'
406 MCK_ld_95_pseudo, // 'ld_pseudo'
407 MCK_le16, // 'le16'
408 MCK_le32, // 'le32'
409 MCK_le64, // 'le64'
410 MCK_lea, // 'lea'
411 MCK_ll, // 'll'
412 MCK_lock, // 'lock'
413 MCK_may_95_goto, // 'may_goto'
414 MCK_s, // 's'
415 MCK_s16, // 's16'
416 MCK_s32, // 's32'
417 MCK_s8, // 's8'
418 MCK_skb, // 'skb'
419 MCK_u16, // 'u16'
420 MCK_u32, // 'u32'
421 MCK_u64, // 'u64'
422 MCK_u8, // 'u8'
423 MCK_xchg32_95_32, // 'xchg32_32'
424 MCK_xchg_95_64, // 'xchg_64'
425 MCK__124_, // '|'
426 MCK_LAST_TOKEN = MCK__124_,
427 MCK_R0, // register class 'R0'
428 MCK_W0, // register class 'W0'
429 MCK_GPR, // register class 'GPR'
430 MCK_GPR32, // register class 'GPR32'
431 MCK_LAST_REGISTER = MCK_GPR32,
432 MCK_Imm, // user defined class 'ImmAsmOperand'
433 MCK_SImm16, // user defined class 'SImm16AsmOperand'
434 MCK_BrTarget, // user defined class 'anonymous_8041'
435 NumMatchClassKinds
436};
437
438} // end anonymous namespace
439
440static unsigned getDiagKindFromRegisterClass(MatchClassKind RegisterClass) {
441 return MCTargetAsmParser::Match_InvalidOperand;
442}
443
444static MatchClassKind matchTokenString(StringRef Name) {
445 switch (Name.size()) {
446 default: break;
447 case 1: // 17 strings to match.
448 switch (Name[0]) {
449 default: break;
450 case '!': // 1 string to match.
451 return MCK__EXCLAIM_; // "!"
452 case '%': // 1 string to match.
453 return MCK__PCT_; // "%"
454 case '&': // 1 string to match.
455 return MCK__38_; // "&"
456 case '(': // 1 string to match.
457 return MCK__40_; // "("
458 case ')': // 1 string to match.
459 return MCK__41_; // ")"
460 case '*': // 1 string to match.
461 return MCK__STAR_; // "*"
462 case '+': // 1 string to match.
463 return MCK__43_; // "+"
464 case '-': // 1 string to match.
465 return MCK__MINUS_; // "-"
466 case '/': // 1 string to match.
467 return MCK__47_; // "/"
468 case '<': // 1 string to match.
469 return MCK__LT_; // "<"
470 case '=': // 1 string to match.
471 return MCK__61_; // "="
472 case '>': // 1 string to match.
473 return MCK__GT_; // ">"
474 case '[': // 1 string to match.
475 return MCK__91_; // "["
476 case ']': // 1 string to match.
477 return MCK__93_; // "]"
478 case '^': // 1 string to match.
479 return MCK__94_; // "^"
480 case 's': // 1 string to match.
481 return MCK_s; // "s"
482 case '|': // 1 string to match.
483 return MCK__124_; // "|"
484 }
485 break;
486 case 2: // 4 strings to match.
487 switch (Name[0]) {
488 default: break;
489 case 'i': // 1 string to match.
490 if (Name[1] != 'f')
491 break;
492 return MCK_if; // "if"
493 case 'l': // 1 string to match.
494 if (Name[1] != 'l')
495 break;
496 return MCK_ll; // "ll"
497 case 's': // 1 string to match.
498 if (Name[1] != '8')
499 break;
500 return MCK_s8; // "s8"
501 case 'u': // 1 string to match.
502 if (Name[1] != '8')
503 break;
504 return MCK_u8; // "u8"
505 }
506 break;
507 case 3: // 7 strings to match.
508 switch (Name[0]) {
509 default: break;
510 case 'l': // 1 string to match.
511 if (memcmp(Name.data()+1, "ea", 2) != 0)
512 break;
513 return MCK_lea; // "lea"
514 case 's': // 3 strings to match.
515 switch (Name[1]) {
516 default: break;
517 case '1': // 1 string to match.
518 if (Name[2] != '6')
519 break;
520 return MCK_s16; // "s16"
521 case '3': // 1 string to match.
522 if (Name[2] != '2')
523 break;
524 return MCK_s32; // "s32"
525 case 'k': // 1 string to match.
526 if (Name[2] != 'b')
527 break;
528 return MCK_skb; // "skb"
529 }
530 break;
531 case 'u': // 3 strings to match.
532 switch (Name[1]) {
533 default: break;
534 case '1': // 1 string to match.
535 if (Name[2] != '6')
536 break;
537 return MCK_u16; // "u16"
538 case '3': // 1 string to match.
539 if (Name[2] != '2')
540 break;
541 return MCK_u32; // "u32"
542 case '6': // 1 string to match.
543 if (Name[2] != '4')
544 break;
545 return MCK_u64; // "u64"
546 }
547 break;
548 }
549 break;
550 case 4: // 10 strings to match.
551 switch (Name[0]) {
552 default: break;
553 case 'b': // 3 strings to match.
554 if (Name[1] != 'e')
555 break;
556 switch (Name[2]) {
557 default: break;
558 case '1': // 1 string to match.
559 if (Name[3] != '6')
560 break;
561 return MCK_be16; // "be16"
562 case '3': // 1 string to match.
563 if (Name[3] != '2')
564 break;
565 return MCK_be32; // "be32"
566 case '6': // 1 string to match.
567 if (Name[3] != '4')
568 break;
569 return MCK_be64; // "be64"
570 }
571 break;
572 case 'c': // 1 string to match.
573 if (memcmp(Name.data()+1, "all", 3) != 0)
574 break;
575 return MCK_call; // "call"
576 case 'e': // 1 string to match.
577 if (memcmp(Name.data()+1, "xit", 3) != 0)
578 break;
579 return MCK_exit; // "exit"
580 case 'g': // 1 string to match.
581 if (memcmp(Name.data()+1, "oto", 3) != 0)
582 break;
583 return MCK_goto; // "goto"
584 case 'l': // 4 strings to match.
585 switch (Name[1]) {
586 default: break;
587 case 'e': // 3 strings to match.
588 switch (Name[2]) {
589 default: break;
590 case '1': // 1 string to match.
591 if (Name[3] != '6')
592 break;
593 return MCK_le16; // "le16"
594 case '3': // 1 string to match.
595 if (Name[3] != '2')
596 break;
597 return MCK_le32; // "le32"
598 case '6': // 1 string to match.
599 if (Name[3] != '4')
600 break;
601 return MCK_le64; // "le64"
602 }
603 break;
604 case 'o': // 1 string to match.
605 if (memcmp(Name.data()+2, "ck", 2) != 0)
606 break;
607 return MCK_lock; // "lock"
608 }
609 break;
610 }
611 break;
612 case 5: // 2 strings to match.
613 switch (Name[0]) {
614 default: break;
615 case 'c': // 1 string to match.
616 if (memcmp(Name.data()+1, "allx", 4) != 0)
617 break;
618 return MCK_callx; // "callx"
619 case 'g': // 1 string to match.
620 if (memcmp(Name.data()+1, "otol", 4) != 0)
621 break;
622 return MCK_gotol; // "gotol"
623 }
624 break;
625 case 7: // 4 strings to match.
626 switch (Name[0]) {
627 default: break;
628 case 'b': // 3 strings to match.
629 if (memcmp(Name.data()+1, "swap", 4) != 0)
630 break;
631 switch (Name[5]) {
632 default: break;
633 case '1': // 1 string to match.
634 if (Name[6] != '6')
635 break;
636 return MCK_bswap16; // "bswap16"
637 case '3': // 1 string to match.
638 if (Name[6] != '2')
639 break;
640 return MCK_bswap32; // "bswap32"
641 case '6': // 1 string to match.
642 if (Name[6] != '4')
643 break;
644 return MCK_bswap64; // "bswap64"
645 }
646 break;
647 case 'x': // 1 string to match.
648 if (memcmp(Name.data()+1, "chg_64", 6) != 0)
649 break;
650 return MCK_xchg_95_64; // "xchg_64"
651 }
652 break;
653 case 8: // 1 string to match.
654 if (memcmp(Name.data()+0, "may_goto", 8) != 0)
655 break;
656 return MCK_may_95_goto; // "may_goto"
657 case 9: // 2 strings to match.
658 switch (Name[0]) {
659 default: break;
660 case 'l': // 1 string to match.
661 if (memcmp(Name.data()+1, "d_pseudo", 8) != 0)
662 break;
663 return MCK_ld_95_pseudo; // "ld_pseudo"
664 case 'x': // 1 string to match.
665 if (memcmp(Name.data()+1, "chg32_32", 8) != 0)
666 break;
667 return MCK_xchg32_95_32; // "xchg32_32"
668 }
669 break;
670 case 10: // 1 string to match.
671 if (memcmp(Name.data()+0, "cmpxchg_64", 10) != 0)
672 break;
673 return MCK_cmpxchg_95_64; // "cmpxchg_64"
674 case 12: // 1 string to match.
675 if (memcmp(Name.data()+0, "cmpxchg32_32", 12) != 0)
676 break;
677 return MCK_cmpxchg32_95_32; // "cmpxchg32_32"
678 case 15: // 2 strings to match.
679 if (Name[0] != 'a')
680 break;
681 switch (Name[1]) {
682 default: break;
683 case 'd': // 1 string to match.
684 if (memcmp(Name.data()+2, "dr_space_cast", 13) != 0)
685 break;
686 return MCK_addr_95_space_95_cast; // "addr_space_cast"
687 case 't': // 1 string to match.
688 if (memcmp(Name.data()+2, "omic_fetch_or", 13) != 0)
689 break;
690 return MCK_atomic_95_fetch_95_or; // "atomic_fetch_or"
691 }
692 break;
693 case 16: // 3 strings to match.
694 if (memcmp(Name.data()+0, "atomic_fetch_", 13) != 0)
695 break;
696 switch (Name[13]) {
697 default: break;
698 case 'a': // 2 strings to match.
699 switch (Name[14]) {
700 default: break;
701 case 'd': // 1 string to match.
702 if (Name[15] != 'd')
703 break;
704 return MCK_atomic_95_fetch_95_add; // "atomic_fetch_add"
705 case 'n': // 1 string to match.
706 if (Name[15] != 'd')
707 break;
708 return MCK_atomic_95_fetch_95_and; // "atomic_fetch_and"
709 }
710 break;
711 case 'x': // 1 string to match.
712 if (memcmp(Name.data()+14, "or", 2) != 0)
713 break;
714 return MCK_atomic_95_fetch_95_xor; // "atomic_fetch_xor"
715 }
716 break;
717 }
718 return InvalidMatchClass;
719}
720
721/// isSubclass - Compute whether \p A is a subclass of \p B.
722static bool isSubclass(MatchClassKind A, MatchClassKind B) {
723 if (A == B)
724 return true;
725
726 switch (A) {
727 default:
728 return false;
729
730 case MCK_R0:
731 return B == MCK_GPR;
732
733 case MCK_W0:
734 return B == MCK_GPR32;
735 }
736}
737
738static unsigned validateOperandClass(MCParsedAsmOperand &GOp, MatchClassKind Kind) {
739 BPFOperand &Operand = (BPFOperand &)GOp;
740 if (Kind == InvalidMatchClass)
741 return MCTargetAsmParser::Match_InvalidOperand;
742
743 if (Operand.isToken() && Kind <= MCK_LAST_TOKEN)
744 return isSubclass(matchTokenString(Operand.getToken()), Kind) ?
745 MCTargetAsmParser::Match_Success :
746 MCTargetAsmParser::Match_InvalidOperand;
747
748 switch (Kind) {
749 default: break;
750 // 'Imm' class
751 case MCK_Imm: {
752 DiagnosticPredicate DP(Operand.isImm());
753 if (DP.isMatch())
754 return MCTargetAsmParser::Match_Success;
755 break;
756 }
757 // 'SImm16' class
758 case MCK_SImm16: {
759 DiagnosticPredicate DP(Operand.isSImm16());
760 if (DP.isMatch())
761 return MCTargetAsmParser::Match_Success;
762 if (DP.isNearMatch())
763 return BPFAsmParser::Match_InvalidSImm16;
764 break;
765 }
766 // 'BrTarget' class
767 case MCK_BrTarget: {
768 DiagnosticPredicate DP(Operand.isBrTarget());
769 if (DP.isMatch())
770 return MCTargetAsmParser::Match_Success;
771 if (DP.isNearMatch())
772 return BPFAsmParser::Match_InvalidBrTarget;
773 break;
774 }
775 } // end switch (Kind)
776
777 if (Operand.isReg()) {
778 MatchClassKind OpKind;
779 switch (Operand.getReg().id()) {
780 default: OpKind = InvalidMatchClass; break;
781 case BPF::W0: OpKind = MCK_W0; break;
782 case BPF::R0: OpKind = MCK_R0; break;
783 case BPF::W1: OpKind = MCK_GPR32; break;
784 case BPF::R1: OpKind = MCK_GPR; break;
785 case BPF::W2: OpKind = MCK_GPR32; break;
786 case BPF::R2: OpKind = MCK_GPR; break;
787 case BPF::W3: OpKind = MCK_GPR32; break;
788 case BPF::R3: OpKind = MCK_GPR; break;
789 case BPF::W4: OpKind = MCK_GPR32; break;
790 case BPF::R4: OpKind = MCK_GPR; break;
791 case BPF::W5: OpKind = MCK_GPR32; break;
792 case BPF::R5: OpKind = MCK_GPR; break;
793 case BPF::W6: OpKind = MCK_GPR32; break;
794 case BPF::R6: OpKind = MCK_GPR; break;
795 case BPF::W7: OpKind = MCK_GPR32; break;
796 case BPF::R7: OpKind = MCK_GPR; break;
797 case BPF::W8: OpKind = MCK_GPR32; break;
798 case BPF::R8: OpKind = MCK_GPR; break;
799 case BPF::W9: OpKind = MCK_GPR32; break;
800 case BPF::R9: OpKind = MCK_GPR; break;
801 case BPF::W10: OpKind = MCK_GPR32; break;
802 case BPF::R10: OpKind = MCK_GPR; break;
803 case BPF::W11: OpKind = MCK_GPR32; break;
804 case BPF::R11: OpKind = MCK_GPR; break;
805 }
806 return isSubclass(OpKind, Kind) ? (unsigned)MCTargetAsmParser::Match_Success :
807 getDiagKindFromRegisterClass(Kind);
808 }
809
810 if (Kind > MCK_LAST_TOKEN && Kind <= MCK_LAST_REGISTER)
811 return getDiagKindFromRegisterClass(Kind);
812
813 return MCTargetAsmParser::Match_InvalidOperand;
814}
815
816#ifndef NDEBUG
817const char *getMatchClassName(MatchClassKind Kind) {
818 switch (Kind) {
819 case InvalidMatchClass: return "InvalidMatchClass";
820 case OptionalMatchClass: return "OptionalMatchClass";
821 case MCK__EXCLAIM_: return "MCK__EXCLAIM_";
822 case MCK__PCT_: return "MCK__PCT_";
823 case MCK__38_: return "MCK__38_";
824 case MCK__40_: return "MCK__40_";
825 case MCK__41_: return "MCK__41_";
826 case MCK__STAR_: return "MCK__STAR_";
827 case MCK__43_: return "MCK__43_";
828 case MCK__MINUS_: return "MCK__MINUS_";
829 case MCK__47_: return "MCK__47_";
830 case MCK__LT_: return "MCK__LT_";
831 case MCK__61_: return "MCK__61_";
832 case MCK__GT_: return "MCK__GT_";
833 case MCK__91_: return "MCK__91_";
834 case MCK__93_: return "MCK__93_";
835 case MCK__94_: return "MCK__94_";
836 case MCK_addr_95_space_95_cast: return "MCK_addr_95_space_95_cast";
837 case MCK_atomic_95_fetch_95_add: return "MCK_atomic_95_fetch_95_add";
838 case MCK_atomic_95_fetch_95_and: return "MCK_atomic_95_fetch_95_and";
839 case MCK_atomic_95_fetch_95_or: return "MCK_atomic_95_fetch_95_or";
840 case MCK_atomic_95_fetch_95_xor: return "MCK_atomic_95_fetch_95_xor";
841 case MCK_be16: return "MCK_be16";
842 case MCK_be32: return "MCK_be32";
843 case MCK_be64: return "MCK_be64";
844 case MCK_bswap16: return "MCK_bswap16";
845 case MCK_bswap32: return "MCK_bswap32";
846 case MCK_bswap64: return "MCK_bswap64";
847 case MCK_call: return "MCK_call";
848 case MCK_callx: return "MCK_callx";
849 case MCK_cmpxchg32_95_32: return "MCK_cmpxchg32_95_32";
850 case MCK_cmpxchg_95_64: return "MCK_cmpxchg_95_64";
851 case MCK_exit: return "MCK_exit";
852 case MCK_goto: return "MCK_goto";
853 case MCK_gotol: return "MCK_gotol";
854 case MCK_if: return "MCK_if";
855 case MCK_ld_95_pseudo: return "MCK_ld_95_pseudo";
856 case MCK_le16: return "MCK_le16";
857 case MCK_le32: return "MCK_le32";
858 case MCK_le64: return "MCK_le64";
859 case MCK_lea: return "MCK_lea";
860 case MCK_ll: return "MCK_ll";
861 case MCK_lock: return "MCK_lock";
862 case MCK_may_95_goto: return "MCK_may_95_goto";
863 case MCK_s: return "MCK_s";
864 case MCK_s16: return "MCK_s16";
865 case MCK_s32: return "MCK_s32";
866 case MCK_s8: return "MCK_s8";
867 case MCK_skb: return "MCK_skb";
868 case MCK_u16: return "MCK_u16";
869 case MCK_u32: return "MCK_u32";
870 case MCK_u64: return "MCK_u64";
871 case MCK_u8: return "MCK_u8";
872 case MCK_xchg32_95_32: return "MCK_xchg32_95_32";
873 case MCK_xchg_95_64: return "MCK_xchg_95_64";
874 case MCK__124_: return "MCK__124_";
875 case MCK_R0: return "MCK_R0";
876 case MCK_W0: return "MCK_W0";
877 case MCK_GPR: return "MCK_GPR";
878 case MCK_GPR32: return "MCK_GPR32";
879 case MCK_Imm: return "MCK_Imm";
880 case MCK_SImm16: return "MCK_SImm16";
881 case MCK_BrTarget: return "MCK_BrTarget";
882 case NumMatchClassKinds: return "NumMatchClassKinds";
883 }
884 llvm_unreachable("unhandled MatchClassKind!");
885}
886
887#endif // NDEBUG
888FeatureBitset BPFAsmParser::
889ComputeAvailableFeatures(const FeatureBitset &FB) const {
890 FeatureBitset Features;
891 return Features;
892}
893
894static bool checkAsmTiedOperandConstraints(const BPFAsmParser&AsmParser,
895 unsigned Kind, const OperandVector &Operands,
896 uint64_t &ErrorInfo) {
897 assert(Kind < CVT_NUM_SIGNATURES && "Invalid signature!");
898 const uint8_t *Converter = ConversionTable[Kind];
899 for (const uint8_t *p = Converter; *p; p += 2) {
900 switch (*p) {
901 case CVT_Tied: {
902 unsigned OpIdx = *(p + 1);
903 assert(OpIdx < (size_t)(std::end(TiedAsmOperandTable) -
904 std::begin(TiedAsmOperandTable)) &&
905 "Tied operand not found");
906 unsigned OpndNum1 = TiedAsmOperandTable[OpIdx][1];
907 unsigned OpndNum2 = TiedAsmOperandTable[OpIdx][2];
908 if (OpndNum1 != OpndNum2) {
909 auto &SrcOp1 = Operands[OpndNum1];
910 auto &SrcOp2 = Operands[OpndNum2];
911 if (!AsmParser.areEqualRegs(*SrcOp1, *SrcOp2)) {
912 ErrorInfo = OpndNum2;
913 return false;
914 }
915 }
916 break;
917 }
918 default:
919 break;
920 }
921 }
922 return true;
923}
924
925static const char MnemonicTable[] =
926 "\000\001*\004call\005callx\004exit\004goto\005gotol\002if\tld_pseudo\003"
927 "lea\004lock\010may_goto\002r0\002w0";
928
929// Feature bitsets.
930enum : uint8_t {
931 AMFBS_None,
932};
933
934static constexpr FeatureBitset FeatureBitsets[] = {
935 {}, // AMFBS_None
936};
937
938namespace {
939 struct MatchEntry {
940 uint8_t Mnemonic;
941 uint16_t Opcode;
942 uint8_t ConvertFn;
943 uint8_t RequiredFeaturesIdx;
944 uint8_t Classes[14];
945 StringRef getMnemonic() const {
946 return StringRef(MnemonicTable + Mnemonic + 1,
947 MnemonicTable[Mnemonic]);
948 }
949 };
950
951 // Predicate for searching for an opcode.
952 struct LessOpcode {
953 bool operator()(const MatchEntry &LHS, StringRef RHS) {
954 return LHS.getMnemonic() < RHS;
955 }
956 bool operator()(StringRef LHS, const MatchEntry &RHS) {
957 return LHS < RHS.getMnemonic();
958 }
959 bool operator()(const MatchEntry &LHS, const MatchEntry &RHS) {
960 return LHS.getMnemonic() < RHS.getMnemonic();
961 }
962 };
963} // end anonymous namespace
964
965static const MatchEntry MatchTable0[] = {
966 { 0 /* */, BPF::MOV_rr, Convert__Reg1_0__Reg1_2, AMFBS_None, { MCK_GPR, MCK__61_, MCK_GPR }, },
967 { 0 /* */, BPF::MOV_ri, Convert__Reg1_0__Imm1_2, AMFBS_None, { MCK_GPR, MCK__61_, MCK_Imm }, },
968 { 0 /* */, BPF::MOV_rr_32, Convert__Reg1_0__Reg1_2, AMFBS_None, { MCK_GPR32, MCK__61_, MCK_GPR32 }, },
969 { 0 /* */, BPF::MOV_ri_32, Convert__Reg1_0__Imm1_2, AMFBS_None, { MCK_GPR32, MCK__61_, MCK_Imm }, },
970 { 0 /* */, BPF::MOD_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__PCT_, MCK__61_, MCK_GPR }, },
971 { 0 /* */, BPF::MOD_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__PCT_, MCK__61_, MCK_Imm }, },
972 { 0 /* */, BPF::AND_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__38_, MCK__61_, MCK_GPR }, },
973 { 0 /* */, BPF::AND_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__38_, MCK__61_, MCK_Imm }, },
974 { 0 /* */, BPF::MUL_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__STAR_, MCK__61_, MCK_GPR }, },
975 { 0 /* */, BPF::MUL_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__STAR_, MCK__61_, MCK_Imm }, },
976 { 0 /* */, BPF::ADD_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__43_, MCK__61_, MCK_GPR }, },
977 { 0 /* */, BPF::ADD_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__43_, MCK__61_, MCK_Imm }, },
978 { 0 /* */, BPF::SUB_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__MINUS_, MCK__61_, MCK_GPR }, },
979 { 0 /* */, BPF::SUB_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__MINUS_, MCK__61_, MCK_Imm }, },
980 { 0 /* */, BPF::DIV_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__47_, MCK__61_, MCK_GPR }, },
981 { 0 /* */, BPF::DIV_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__47_, MCK__61_, MCK_Imm }, },
982 { 0 /* */, BPF::NEG_64, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK__MINUS_, MCK_GPR }, },
983 { 0 /* */, BPF::BE16, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_be16, MCK_GPR }, },
984 { 0 /* */, BPF::BE32, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_be32, MCK_GPR }, },
985 { 0 /* */, BPF::BE64, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_be64, MCK_GPR }, },
986 { 0 /* */, BPF::BSWAP16, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_bswap16, MCK_GPR }, },
987 { 0 /* */, BPF::BSWAP32, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_bswap32, MCK_GPR }, },
988 { 0 /* */, BPF::BSWAP64, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_bswap64, MCK_GPR }, },
989 { 0 /* */, BPF::LE16, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_le16, MCK_GPR }, },
990 { 0 /* */, BPF::LE32, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_le32, MCK_GPR }, },
991 { 0 /* */, BPF::LE64, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR, MCK__61_, MCK_le64, MCK_GPR }, },
992 { 0 /* */, BPF::LD_imm64, Convert__Reg1_0__Imm1_2, AMFBS_None, { MCK_GPR, MCK__61_, MCK_Imm, MCK_ll }, },
993 { 0 /* */, BPF::XOR_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__94_, MCK__61_, MCK_GPR }, },
994 { 0 /* */, BPF::XOR_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__94_, MCK__61_, MCK_Imm }, },
995 { 0 /* */, BPF::OR_rr, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR, MCK__124_, MCK__61_, MCK_GPR }, },
996 { 0 /* */, BPF::OR_ri, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR, MCK__124_, MCK__61_, MCK_Imm }, },
997 { 0 /* */, BPF::MOD_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__PCT_, MCK__61_, MCK_GPR32 }, },
998 { 0 /* */, BPF::MOD_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__PCT_, MCK__61_, MCK_Imm }, },
999 { 0 /* */, BPF::AND_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__38_, MCK__61_, MCK_GPR32 }, },
1000 { 0 /* */, BPF::AND_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__38_, MCK__61_, MCK_Imm }, },
1001 { 0 /* */, BPF::MUL_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__STAR_, MCK__61_, MCK_GPR32 }, },
1002 { 0 /* */, BPF::MUL_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__STAR_, MCK__61_, MCK_Imm }, },
1003 { 0 /* */, BPF::ADD_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__43_, MCK__61_, MCK_GPR32 }, },
1004 { 0 /* */, BPF::ADD_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__43_, MCK__61_, MCK_Imm }, },
1005 { 0 /* */, BPF::SUB_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__MINUS_, MCK__61_, MCK_GPR32 }, },
1006 { 0 /* */, BPF::SUB_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__MINUS_, MCK__61_, MCK_Imm }, },
1007 { 0 /* */, BPF::DIV_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__47_, MCK__61_, MCK_GPR32 }, },
1008 { 0 /* */, BPF::DIV_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__47_, MCK__61_, MCK_Imm }, },
1009 { 0 /* */, BPF::NEG_32, Convert__Reg1_0__Tie0_0_3, AMFBS_None, { MCK_GPR32, MCK__61_, MCK__MINUS_, MCK_GPR32 }, },
1010 { 0 /* */, BPF::XOR_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__94_, MCK__61_, MCK_GPR32 }, },
1011 { 0 /* */, BPF::XOR_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__94_, MCK__61_, MCK_Imm }, },
1012 { 0 /* */, BPF::OR_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_3, AMFBS_None, { MCK_GPR32, MCK__124_, MCK__61_, MCK_GPR32 }, },
1013 { 0 /* */, BPF::OR_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_3, AMFBS_None, { MCK_GPR32, MCK__124_, MCK__61_, MCK_Imm }, },
1014 { 0 /* */, BPF::SLL_rr, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR, MCK__LT_, MCK__LT_, MCK__61_, MCK_GPR }, },
1015 { 0 /* */, BPF::SLL_ri, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR, MCK__LT_, MCK__LT_, MCK__61_, MCK_Imm }, },
1016 { 0 /* */, BPF::SRL_rr, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR }, },
1017 { 0 /* */, BPF::SRL_ri, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
1018 { 0 /* */, BPF::SMOD_rr, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR, MCK_s, MCK__PCT_, MCK__61_, MCK_GPR }, },
1019 { 0 /* */, BPF::SMOD_ri, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR, MCK_s, MCK__PCT_, MCK__61_, MCK_Imm }, },
1020 { 0 /* */, BPF::SDIV_rr, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR, MCK_s, MCK__47_, MCK__61_, MCK_GPR }, },
1021 { 0 /* */, BPF::SDIV_ri, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR, MCK_s, MCK__47_, MCK__61_, MCK_Imm }, },
1022 { 0 /* */, BPF::SLL_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR32, MCK__LT_, MCK__LT_, MCK__61_, MCK_GPR32 }, },
1023 { 0 /* */, BPF::SLL_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR32, MCK__LT_, MCK__LT_, MCK__61_, MCK_Imm }, },
1024 { 0 /* */, BPF::SRL_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR32, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR32 }, },
1025 { 0 /* */, BPF::SRL_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR32, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
1026 { 0 /* */, BPF::SMOD_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR32, MCK_s, MCK__PCT_, MCK__61_, MCK_GPR32 }, },
1027 { 0 /* */, BPF::SMOD_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR32, MCK_s, MCK__PCT_, MCK__61_, MCK_Imm }, },
1028 { 0 /* */, BPF::SDIV_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_4, AMFBS_None, { MCK_GPR32, MCK_s, MCK__47_, MCK__61_, MCK_GPR32 }, },
1029 { 0 /* */, BPF::SDIV_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_4, AMFBS_None, { MCK_GPR32, MCK_s, MCK__47_, MCK__61_, MCK_Imm }, },
1030 { 0 /* */, BPF::MOVSX_rr_16, Convert__Reg1_0__Reg1_5, AMFBS_None, { MCK_GPR, MCK__61_, MCK__40_, MCK_s16, MCK__41_, MCK_GPR }, },
1031 { 0 /* */, BPF::MOVSX_rr_32, Convert__Reg1_0__Reg1_5, AMFBS_None, { MCK_GPR, MCK__61_, MCK__40_, MCK_s32, MCK__41_, MCK_GPR }, },
1032 { 0 /* */, BPF::MOVSX_rr_8, Convert__Reg1_0__Reg1_5, AMFBS_None, { MCK_GPR, MCK__61_, MCK__40_, MCK_s8, MCK__41_, MCK_GPR }, },
1033 { 0 /* */, BPF::SRA_rr, Convert__Reg1_0__Tie0_0_0__Reg1_5, AMFBS_None, { MCK_GPR, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR }, },
1034 { 0 /* */, BPF::SRA_ri, Convert__Reg1_0__Tie0_0_0__Imm1_5, AMFBS_None, { MCK_GPR, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
1035 { 0 /* */, BPF::MOVSX_rr_32_16, Convert__Reg1_0__Reg1_5, AMFBS_None, { MCK_GPR32, MCK__61_, MCK__40_, MCK_s16, MCK__41_, MCK_GPR32 }, },
1036 { 0 /* */, BPF::MOVSX_rr_32_8, Convert__Reg1_0__Reg1_5, AMFBS_None, { MCK_GPR32, MCK__61_, MCK__40_, MCK_s8, MCK__41_, MCK_GPR32 }, },
1037 { 0 /* */, BPF::SRA_rr_32, Convert__Reg1_0__Tie0_0_0__Reg1_5, AMFBS_None, { MCK_GPR32, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR32 }, },
1038 { 0 /* */, BPF::SRA_ri_32, Convert__Reg1_0__Tie0_0_0__Imm1_5, AMFBS_None, { MCK_GPR32, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
1039 { 0 /* */, BPF::ADDR_SPACE_CAST, Convert__Reg1_0__Reg1_4__Imm1_5__Imm1_6, AMFBS_None, { MCK_GPR, MCK__61_, MCK_addr_95_space_95_cast, MCK__40_, MCK_GPR, MCK_Imm, MCK_Imm, MCK__41_ }, },
1040 { 0 /* */, BPF::XCHGD, Convert__Reg1_0__Reg1_4__SImm161_5__Tie0_0_6, AMFBS_None, { MCK_GPR, MCK__61_, MCK_xchg_95_64, MCK__40_, MCK_GPR, MCK_SImm16, MCK_GPR, MCK__41_ }, },
1041 { 0 /* */, BPF::XCHGW32, Convert__Reg1_0__Reg1_4__SImm161_5__Tie0_0_6, AMFBS_None, { MCK_GPR32, MCK__61_, MCK_xchg32_95_32, MCK__40_, MCK_GPR, MCK_SImm16, MCK_GPR32, MCK__41_ }, },
1042 { 0 /* */, BPF::LDHSX, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_s16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1043 { 0 /* */, BPF::LDWSX, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_s32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1044 { 0 /* */, BPF::LDBSX, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_s8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1045 { 0 /* */, BPF::LDH, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1046 { 0 /* */, BPF::LDW, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1047 { 0 /* */, BPF::LDD, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1048 { 0 /* */, BPF::LDB, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1049 { 0 /* */, BPF::LDH32, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR32, MCK__61_, MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1050 { 0 /* */, BPF::LDW32, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR32, MCK__61_, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1051 { 0 /* */, BPF::LDB32, Convert__Reg1_0__Reg1_8__SImm161_9, AMFBS_None, { MCK_GPR32, MCK__61_, MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_ }, },
1052 { 0 /* */, BPF::XFADDD, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR, MCK__61_, MCK_atomic_95_fetch_95_add, MCK__40_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR, MCK__41_ }, },
1053 { 0 /* */, BPF::XFANDD, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR, MCK__61_, MCK_atomic_95_fetch_95_and, MCK__40_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR, MCK__41_ }, },
1054 { 0 /* */, BPF::XFORD, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR, MCK__61_, MCK_atomic_95_fetch_95_or, MCK__40_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR, MCK__41_ }, },
1055 { 0 /* */, BPF::XFXORD, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR, MCK__61_, MCK_atomic_95_fetch_95_xor, MCK__40_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR, MCK__41_ }, },
1056 { 0 /* */, BPF::XFADDW32, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR32, MCK__61_, MCK_atomic_95_fetch_95_add, MCK__40_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR32, MCK__41_ }, },
1057 { 0 /* */, BPF::XFANDW32, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR32, MCK__61_, MCK_atomic_95_fetch_95_and, MCK__40_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR32, MCK__41_ }, },
1058 { 0 /* */, BPF::XFORW32, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR32, MCK__61_, MCK_atomic_95_fetch_95_or, MCK__40_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR32, MCK__41_ }, },
1059 { 0 /* */, BPF::XFXORW32, Convert__Reg1_0__Reg1_9__SImm161_10__Tie0_0_12, AMFBS_None, { MCK_GPR32, MCK__61_, MCK_atomic_95_fetch_95_xor, MCK__40_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK_GPR32, MCK__41_ }, },
1060 { 1 /* * */, BPF::STH, Convert__Reg1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_GPR }, },
1061 { 1 /* * */, BPF::STH32, Convert__Reg1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_GPR32 }, },
1062 { 1 /* * */, BPF::STH_imm, Convert__Imm1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_Imm }, },
1063 { 1 /* * */, BPF::STW, Convert__Reg1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_GPR }, },
1064 { 1 /* * */, BPF::STW32, Convert__Reg1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_GPR32 }, },
1065 { 1 /* * */, BPF::STW_imm, Convert__Imm1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_Imm }, },
1066 { 1 /* * */, BPF::STD, Convert__Reg1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_GPR }, },
1067 { 1 /* * */, BPF::STD_imm, Convert__Imm1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_Imm }, },
1068 { 1 /* * */, BPF::STB, Convert__Reg1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_GPR }, },
1069 { 1 /* * */, BPF::STB32, Convert__Reg1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_GPR32 }, },
1070 { 1 /* * */, BPF::STB_imm, Convert__Imm1_10__Reg1_6__SImm161_7, AMFBS_None, { MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__61_, MCK_Imm }, },
1071 { 3 /* call */, BPF::JAL, Convert__Imm1_1, AMFBS_None, { MCK_call, MCK_Imm }, },
1072 { 8 /* callx */, BPF::JALX, Convert__Reg1_1, AMFBS_None, { MCK_callx, MCK_GPR }, },
1073 { 14 /* exit */, BPF::RET, Convert_NoOperands, AMFBS_None, { MCK_exit }, },
1074 { 19 /* goto */, BPF::JMP, Convert__BrTarget1_1, AMFBS_None, { MCK_goto, MCK_BrTarget }, },
1075 { 24 /* gotol */, BPF::JMPL, Convert__BrTarget1_1, AMFBS_None, { MCK_gotol, MCK_BrTarget }, },
1076 { 30 /* if */, BPF::JSET_rr, Convert__Reg1_1__Reg1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR, MCK__38_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1077 { 30 /* if */, BPF::JSET_ri, Convert__Reg1_1__Imm1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR, MCK__38_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1078 { 30 /* if */, BPF::JULT_rr, Convert__Reg1_1__Reg1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR, MCK__LT_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1079 { 30 /* if */, BPF::JULT_ri, Convert__Reg1_1__Imm1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR, MCK__LT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1080 { 30 /* if */, BPF::JUGT_rr, Convert__Reg1_1__Reg1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR, MCK__GT_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1081 { 30 /* if */, BPF::JUGT_ri, Convert__Reg1_1__Imm1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR, MCK__GT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1082 { 30 /* if */, BPF::JSET_rr_32, Convert__Reg1_1__Reg1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR32, MCK__38_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1083 { 30 /* if */, BPF::JSET_ri_32, Convert__Reg1_1__Imm1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR32, MCK__38_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1084 { 30 /* if */, BPF::JULT_rr_32, Convert__Reg1_1__Reg1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR32, MCK__LT_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1085 { 30 /* if */, BPF::JULT_ri_32, Convert__Reg1_1__Imm1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR32, MCK__LT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1086 { 30 /* if */, BPF::JUGT_rr_32, Convert__Reg1_1__Reg1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR32, MCK__GT_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1087 { 30 /* if */, BPF::JUGT_ri_32, Convert__Reg1_1__Imm1_3__BrTarget1_5, AMFBS_None, { MCK_if, MCK_GPR32, MCK__GT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1088 { 30 /* if */, BPF::JNE_rr, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__EXCLAIM_, MCK__61_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1089 { 30 /* if */, BPF::JNE_ri, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__EXCLAIM_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1090 { 30 /* if */, BPF::JULE_rr, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__LT_, MCK__61_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1091 { 30 /* if */, BPF::JULE_ri, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__LT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1092 { 30 /* if */, BPF::JEQ_rr, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__61_, MCK__61_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1093 { 30 /* if */, BPF::JEQ_ri, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__61_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1094 { 30 /* if */, BPF::JUGE_rr, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__GT_, MCK__61_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1095 { 30 /* if */, BPF::JUGE_ri, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK__GT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1096 { 30 /* if */, BPF::JSLT_rr, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1097 { 30 /* if */, BPF::JSLT_ri, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1098 { 30 /* if */, BPF::JSGT_rr, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1099 { 30 /* if */, BPF::JSGT_ri, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1100 { 30 /* if */, BPF::JNE_rr_32, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__EXCLAIM_, MCK__61_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1101 { 30 /* if */, BPF::JNE_ri_32, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__EXCLAIM_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1102 { 30 /* if */, BPF::JULE_rr_32, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__LT_, MCK__61_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1103 { 30 /* if */, BPF::JULE_ri_32, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__LT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1104 { 30 /* if */, BPF::JEQ_rr_32, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__61_, MCK__61_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1105 { 30 /* if */, BPF::JEQ_ri_32, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__61_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1106 { 30 /* if */, BPF::JUGE_rr_32, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__GT_, MCK__61_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1107 { 30 /* if */, BPF::JUGE_ri_32, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK__GT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1108 { 30 /* if */, BPF::JSLT_rr_32, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__LT_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1109 { 30 /* if */, BPF::JSLT_ri_32, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__LT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1110 { 30 /* if */, BPF::JSGT_rr_32, Convert__Reg1_1__Reg1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__GT_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1111 { 30 /* if */, BPF::JSGT_ri_32, Convert__Reg1_1__Imm1_4__BrTarget1_6, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__GT_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1112 { 30 /* if */, BPF::JSLE_rr, Convert__Reg1_1__Reg1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK__61_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1113 { 30 /* if */, BPF::JSLE_ri, Convert__Reg1_1__Imm1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1114 { 30 /* if */, BPF::JSGE_rr, Convert__Reg1_1__Reg1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK__61_, MCK_GPR, MCK_goto, MCK_BrTarget }, },
1115 { 30 /* if */, BPF::JSGE_ri, Convert__Reg1_1__Imm1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1116 { 30 /* if */, BPF::JSLE_rr_32, Convert__Reg1_1__Reg1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__LT_, MCK__61_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1117 { 30 /* if */, BPF::JSLE_ri_32, Convert__Reg1_1__Imm1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__LT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1118 { 30 /* if */, BPF::JSGE_rr_32, Convert__Reg1_1__Reg1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__GT_, MCK__61_, MCK_GPR32, MCK_goto, MCK_BrTarget }, },
1119 { 30 /* if */, BPF::JSGE_ri_32, Convert__Reg1_1__Imm1_5__BrTarget1_7, AMFBS_None, { MCK_if, MCK_GPR32, MCK_s, MCK__GT_, MCK__61_, MCK_Imm, MCK_goto, MCK_BrTarget }, },
1120 { 33 /* ld_pseudo */, BPF::LD_pseudo, Convert__Reg1_1__Imm1_2__Imm1_3, AMFBS_None, { MCK_ld_95_pseudo, MCK_GPR, MCK_Imm, MCK_Imm }, },
1121 { 43 /* lea */, BPF::FI_ri, Convert__Reg1_1__Reg1_2__SImm161_3, AMFBS_None, { MCK_lea, MCK_GPR, MCK_GPR, MCK_SImm16 }, },
1122 { 47 /* lock */, BPF::XANDW32, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__38_, MCK__61_, MCK_GPR32 }, },
1123 { 47 /* lock */, BPF::XADDW, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__43_, MCK__61_, MCK_GPR }, },
1124 { 47 /* lock */, BPF::XADDW32, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__43_, MCK__61_, MCK_GPR32 }, },
1125 { 47 /* lock */, BPF::XXORW32, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__94_, MCK__61_, MCK_GPR32 }, },
1126 { 47 /* lock */, BPF::XORW32, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__124_, MCK__61_, MCK_GPR32 }, },
1127 { 47 /* lock */, BPF::XANDD, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__38_, MCK__61_, MCK_GPR }, },
1128 { 47 /* lock */, BPF::XADDD, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__43_, MCK__61_, MCK_GPR }, },
1129 { 47 /* lock */, BPF::XXORD, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__94_, MCK__61_, MCK_GPR }, },
1130 { 47 /* lock */, BPF::XORD, Convert__Reg1_12__Reg1_7__SImm161_8__Tie0_12_12, AMFBS_None, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_SImm16, MCK__41_, MCK__124_, MCK__61_, MCK_GPR }, },
1131 { 52 /* may_goto */, BPF::JCOND, Convert__BrTarget1_1, AMFBS_None, { MCK_may_95_goto, MCK_BrTarget }, },
1132 { 61 /* r0 */, BPF::CMPXCHGD, Convert__Reg1_4__SImm161_5__Reg1_7, AMFBS_None, { MCK_R0, MCK__61_, MCK_cmpxchg_95_64, MCK__40_, MCK_GPR, MCK_SImm16, MCK_R0, MCK_GPR, MCK__41_ }, },
1133 { 61 /* r0 */, BPF::LD_IND_H, Convert__imm_95_0__Reg1_9, AMFBS_None, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_GPR, MCK__93_ }, },
1134 { 61 /* r0 */, BPF::LD_ABS_H, Convert__imm_95_0__Imm1_9, AMFBS_None, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_Imm, MCK__93_ }, },
1135 { 61 /* r0 */, BPF::LD_IND_W, Convert__imm_95_0__Reg1_9, AMFBS_None, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_GPR, MCK__93_ }, },
1136 { 61 /* r0 */, BPF::LD_ABS_W, Convert__imm_95_0__Imm1_9, AMFBS_None, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_Imm, MCK__93_ }, },
1137 { 61 /* r0 */, BPF::LD_IND_B, Convert__imm_95_0__Reg1_9, AMFBS_None, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_GPR, MCK__93_ }, },
1138 { 61 /* r0 */, BPF::LD_ABS_B, Convert__imm_95_0__Imm1_9, AMFBS_None, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_Imm, MCK__93_ }, },
1139 { 64 /* w0 */, BPF::CMPXCHGW32, Convert__Reg1_4__SImm161_5__Reg1_7, AMFBS_None, { MCK_W0, MCK__61_, MCK_cmpxchg32_95_32, MCK__40_, MCK_GPR, MCK_SImm16, MCK_W0, MCK_GPR32, MCK__41_ }, },
1140};
1141
1142#include "llvm/Support/Debug.h"
1143#include "llvm/Support/Format.h"
1144
1145unsigned BPFAsmParser::
1146MatchInstructionImpl(const OperandVector &Operands,
1147 MCInst &Inst,
1148 uint64_t &ErrorInfo,
1149 FeatureBitset &MissingFeatures,
1150 bool matchingInlineAsm, unsigned VariantID) {
1151 // Eliminate obvious mismatches.
1152 if (Operands.size() > 14) {
1153 ErrorInfo = 14;
1154 return Match_InvalidOperand;
1155 }
1156
1157 // Get the current feature set.
1158 const FeatureBitset &AvailableFeatures = getAvailableFeatures();
1159
1160 // Get the instruction mnemonic, which is the first token.
1161 StringRef Mnemonic;
1162 if (Operands[0]->isToken())
1163 Mnemonic = ((BPFOperand &)*Operands[0]).getToken();
1164
1165 // Some state to try to produce better error messages.
1166 bool HadMatchOtherThanFeatures = false;
1167 bool HadMatchOtherThanPredicate = false;
1168 unsigned RetCode = Match_InvalidOperand;
1169 MissingFeatures.set();
1170 // Set ErrorInfo to the operand that mismatches if it is
1171 // wrong for all instances of the instruction.
1172 ErrorInfo = ~0ULL;
1173 // Find the appropriate table for this asm variant.
1174 const MatchEntry *Start, *End;
1175 switch (VariantID) {
1176 default: llvm_unreachable("invalid variant!");
1177 case 0: Start = std::begin(MatchTable0); End = std::end(MatchTable0); break;
1178 }
1179 // Search the table.
1180 auto MnemonicRange = std::pair(Start, End);
1181 unsigned SIndex = Mnemonic.empty() ? 0 : 1;
1182 if (!Mnemonic.empty())
1183 MnemonicRange = std::equal_range(Start, End, Mnemonic.lower(), LessOpcode());
1184
1185 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "AsmMatcher: found " <<
1186 std::distance(MnemonicRange.first, MnemonicRange.second) <<
1187 " encodings with mnemonic '" << Mnemonic << "'\n");
1188
1189 // Return a more specific error code if no mnemonics match.
1190 if (MnemonicRange.first == MnemonicRange.second)
1191 return Match_MnemonicFail;
1192
1193 for (const MatchEntry *it = MnemonicRange.first, *ie = MnemonicRange.second;
1194 it != ie; ++it) {
1195 const FeatureBitset &RequiredFeatures = FeatureBitsets[it->RequiredFeaturesIdx];
1196 bool HasRequiredFeatures =
1197 (AvailableFeatures & RequiredFeatures) == RequiredFeatures;
1198 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "Trying to match opcode "
1199 << MII.getName(it->Opcode) << "\n");
1200 bool OperandsValid = true;
1201 for (unsigned FormalIdx = SIndex, ActualIdx = SIndex; FormalIdx != 14; ++FormalIdx) {
1202 auto Formal = static_cast<MatchClassKind>(it->Classes[FormalIdx]);
1203 DEBUG_WITH_TYPE("asm-matcher",
1204 dbgs() << " Matching formal operand class " << getMatchClassName(Formal)
1205 << " against actual operand at index " << ActualIdx);
1206 if (ActualIdx < Operands.size())
1207 DEBUG_WITH_TYPE("asm-matcher", dbgs() << " (";
1208 Operands[ActualIdx]->print(dbgs()); dbgs() << "): ");
1209 else
1210 DEBUG_WITH_TYPE("asm-matcher", dbgs() << ": ");
1211 if (ActualIdx >= Operands.size()) {
1212 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "actual operand index out of range\n");
1213 if (Formal == InvalidMatchClass) {
1214 break;
1215 }
1216 if (isSubclass(Formal, OptionalMatchClass)) {
1217 continue;
1218 }
1219 OperandsValid = false;
1220 ErrorInfo = ActualIdx;
1221 break;
1222 }
1223 MCParsedAsmOperand &Actual = *Operands[ActualIdx];
1224 unsigned Diag = validateOperandClass(Actual, Formal);
1225 if (Diag == Match_Success) {
1226 DEBUG_WITH_TYPE("asm-matcher",
1227 dbgs() << "match success using generic matcher\n");
1228 ++ActualIdx;
1229 continue;
1230 }
1231 // If the generic handler indicates an invalid operand
1232 // failure, check for a special case.
1233 if (Diag != Match_Success) {
1234 unsigned TargetDiag = validateTargetOperandClass(Actual, Formal);
1235 if (TargetDiag == Match_Success) {
1236 DEBUG_WITH_TYPE("asm-matcher",
1237 dbgs() << "match success using target matcher\n");
1238 ++ActualIdx;
1239 continue;
1240 }
1241 // If the target matcher returned a specific error code use
1242 // that, else use the one from the generic matcher.
1243 if (TargetDiag != Match_InvalidOperand && HasRequiredFeatures)
1244 Diag = TargetDiag;
1245 }
1246 // If current formal operand wasn't matched and it is optional
1247 // then try to match next formal operand
1248 if (Diag == Match_InvalidOperand && isSubclass(Formal, OptionalMatchClass)) {
1249 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "ignoring optional operand\n");
1250 continue;
1251 }
1252 // If this operand is broken for all of the instances of this
1253 // mnemonic, keep track of it so we can report loc info.
1254 // If we already had a match that only failed due to a
1255 // target predicate, that diagnostic is preferred.
1256 if (!HadMatchOtherThanPredicate &&
1257 (it == MnemonicRange.first || ErrorInfo <= ActualIdx)) {
1258 if (HasRequiredFeatures && (ErrorInfo != ActualIdx || Diag != Match_InvalidOperand))
1259 RetCode = Diag;
1260 ErrorInfo = ActualIdx;
1261 }
1262 // Otherwise, just reject this instance of the mnemonic.
1263 OperandsValid = false;
1264 break;
1265 }
1266
1267 if (!OperandsValid) {
1268 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "Opcode result: multiple "
1269 "operand mismatches, ignoring "
1270 "this opcode\n");
1271 continue;
1272 }
1273 if (!HasRequiredFeatures) {
1274 HadMatchOtherThanFeatures = true;
1275 FeatureBitset NewMissingFeatures = RequiredFeatures & ~AvailableFeatures;
1276 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "Missing target features:";
1277 for (unsigned I = 0, E = NewMissingFeatures.size(); I != E; ++I)
1278 if (NewMissingFeatures[I])
1279 dbgs() << ' ' << I;
1280 dbgs() << "\n");
1281 if (NewMissingFeatures.count() <=
1282 MissingFeatures.count())
1283 MissingFeatures = NewMissingFeatures;
1284 continue;
1285 }
1286
1287 Inst.clear();
1288
1289 Inst.setOpcode(it->Opcode);
1290 // We have a potential match but have not rendered the operands.
1291 // Check the target predicate to handle any context sensitive
1292 // constraints.
1293 // For example, Ties that are referenced multiple times must be
1294 // checked here to ensure the input is the same for each match
1295 // constraints. If we leave it any later the ties will have been
1296 // canonicalized
1297 unsigned MatchResult;
1298 if ((MatchResult = checkEarlyTargetMatchPredicate(Inst, Operands)) != Match_Success) {
1299 Inst.clear();
1300 DEBUG_WITH_TYPE(
1301 "asm-matcher",
1302 dbgs() << "Early target match predicate failed with diag code "
1303 << MatchResult << "\n");
1304 RetCode = MatchResult;
1305 HadMatchOtherThanPredicate = true;
1306 continue;
1307 }
1308
1309 if (matchingInlineAsm) {
1310 convertToMapAndConstraints(it->ConvertFn, Operands);
1311 if (!checkAsmTiedOperandConstraints(*this, it->ConvertFn, Operands,
1312 ErrorInfo))
1313 return Match_InvalidTiedOperand;
1314
1315 return Match_Success;
1316 }
1317
1318 // We have selected a definite instruction, convert the parsed
1319 // operands into the appropriate MCInst.
1320 convertToMCInst(it->ConvertFn, Inst, it->Opcode, Operands);
1321
1322 // We have a potential match. Check the target predicate to
1323 // handle any context sensitive constraints.
1324 if ((MatchResult = checkTargetMatchPredicate(Inst)) != Match_Success) {
1325 DEBUG_WITH_TYPE("asm-matcher",
1326 dbgs() << "Target match predicate failed with diag code "
1327 << MatchResult << "\n");
1328 Inst.clear();
1329 RetCode = MatchResult;
1330 HadMatchOtherThanPredicate = true;
1331 continue;
1332 }
1333
1334 if (!checkAsmTiedOperandConstraints(*this, it->ConvertFn, Operands,
1335 ErrorInfo))
1336 return Match_InvalidTiedOperand;
1337
1338 DEBUG_WITH_TYPE(
1339 "asm-matcher",
1340 dbgs() << "Opcode result: complete match, selecting this opcode\n");
1341 return Match_Success;
1342 }
1343
1344 // Okay, we had no match. Try to return a useful error code.
1345 if (HadMatchOtherThanPredicate || !HadMatchOtherThanFeatures)
1346 return RetCode;
1347
1348 ErrorInfo = 0;
1349 return Match_MissingFeature;
1350}
1351
1352#endif // GET_MATCHER_IMPLEMENTATION
1353
1354
1355#ifdef GET_MNEMONIC_SPELL_CHECKER
1356#undef GET_MNEMONIC_SPELL_CHECKER
1357
1358static std::string BPFMnemonicSpellCheck(StringRef S, const FeatureBitset &FBS, unsigned VariantID) {
1359 const unsigned MaxEditDist = 2;
1360 std::vector<StringRef> Candidates;
1361 StringRef Prev = "";
1362
1363 // Find the appropriate table for this asm variant.
1364 const MatchEntry *Start, *End;
1365 switch (VariantID) {
1366 default: llvm_unreachable("invalid variant!");
1367 case 0: Start = std::begin(MatchTable0); End = std::end(MatchTable0); break;
1368 }
1369
1370 for (auto I = Start; I < End; I++) {
1371 // Ignore unsupported instructions.
1372 const FeatureBitset &RequiredFeatures = FeatureBitsets[I->RequiredFeaturesIdx];
1373 if ((FBS & RequiredFeatures) != RequiredFeatures)
1374 continue;
1375
1376 StringRef T = I->getMnemonic();
1377 // Avoid recomputing the edit distance for the same string.
1378 if (T == Prev)
1379 continue;
1380
1381 Prev = T;
1382 unsigned Dist = S.edit_distance(T, false, MaxEditDist);
1383 if (Dist <= MaxEditDist)
1384 Candidates.push_back(T);
1385 }
1386
1387 if (Candidates.empty())
1388 return "";
1389
1390 std::string Res = ", did you mean: ";
1391 unsigned i = 0;
1392 for (; i < Candidates.size() - 1; i++)
1393 Res += Candidates[i].str() + ", ";
1394 return Res + Candidates[i].str() + "?";
1395}
1396
1397#endif // GET_MNEMONIC_SPELL_CHECKER
1398
1399
1400#ifdef GET_MNEMONIC_CHECKER
1401#undef GET_MNEMONIC_CHECKER
1402
1403static bool BPFCheckMnemonic(StringRef Mnemonic,
1404 const FeatureBitset &AvailableFeatures,
1405 unsigned VariantID) {
1406 // Find the appropriate table for this asm variant.
1407 const MatchEntry *Start, *End;
1408 switch (VariantID) {
1409 default: llvm_unreachable("invalid variant!");
1410 case 0: Start = std::begin(MatchTable0); End = std::end(MatchTable0); break;
1411 }
1412
1413 // Search the table.
1414 auto MnemonicRange = std::pair(Start, End);
1415 unsigned SIndex = Mnemonic.empty() ? 0 : 1;
1416 if (!Mnemonic.empty())
1417 MnemonicRange = std::equal_range(Start, End, Mnemonic.lower(), LessOpcode());
1418
1419 if (MnemonicRange.first == MnemonicRange.second)
1420 return false;
1421
1422 for (const MatchEntry *it = MnemonicRange.first, *ie = MnemonicRange.second;
1423 it != ie; ++it) {
1424 const FeatureBitset &RequiredFeatures =
1425 FeatureBitsets[it->RequiredFeaturesIdx];
1426 if ((AvailableFeatures & RequiredFeatures) == RequiredFeatures)
1427 return true;
1428 }
1429 return false;
1430}
1431
1432#endif // GET_MNEMONIC_CHECKER
1433
1434