Bug Summary

File:build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc
Warning:line 715, column 10
Excessive padding in 'struct (anonymous namespace)::MatchEntry' (2 padding bytes, where 0 is optimal). Optimal fields order: Opcode, Mnemonic, ConvertFn, RequiredFeatures, Classes, consider reordering the fields or adding explicit padding members

Annotated Source Code

1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Assembly Matcher Source Fragment *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9
10#ifdef GET_ASSEMBLER_HEADER
11#undef GET_ASSEMBLER_HEADER
12 // This should be included into the middle of the declaration of
13 // your subclasses implementation of MCTargetAsmParser.
14 uint64_t ComputeAvailableFeatures(const FeatureBitset& FB) const;
15 void convertToMCInst(unsigned Kind, MCInst &Inst, unsigned Opcode,
16 const OperandVector &Operands);
17 void convertToMapAndConstraints(unsigned Kind,
18 const OperandVector &Operands) override;
19 unsigned MatchInstructionImpl(const OperandVector &Operands,
20 MCInst &Inst,
21 uint64_t &ErrorInfo,
22 bool matchingInlineAsm,
23 unsigned VariantID = 0);
24#endif // GET_ASSEMBLER_HEADER_INFO
25
26
27#ifdef GET_OPERAND_DIAGNOSTIC_TYPES
28#undef GET_OPERAND_DIAGNOSTIC_TYPES
29
30#endif // GET_OPERAND_DIAGNOSTIC_TYPES
31
32
33#ifdef GET_REGISTER_MATCHER
34#undef GET_REGISTER_MATCHER
35
36// Flags for subtarget features that participate in instruction matching.
37enum SubtargetFeatureFlag : uint8_t {
38 Feature_None = 0
39};
40
41static unsigned MatchRegisterName(StringRef Name) {
42 switch (Name.size()) {
43 default: break;
44 case 2: // 20 strings to match.
45 switch (Name[0]) {
46 default: break;
47 case 'r': // 10 strings to match.
48 switch (Name[1]) {
49 default: break;
50 case '0': // 1 string to match.
51 return 1; // "r0"
52 case '1': // 1 string to match.
53 return 2; // "r1"
54 case '2': // 1 string to match.
55 return 3; // "r2"
56 case '3': // 1 string to match.
57 return 4; // "r3"
58 case '4': // 1 string to match.
59 return 5; // "r4"
60 case '5': // 1 string to match.
61 return 6; // "r5"
62 case '6': // 1 string to match.
63 return 7; // "r6"
64 case '7': // 1 string to match.
65 return 8; // "r7"
66 case '8': // 1 string to match.
67 return 9; // "r8"
68 case '9': // 1 string to match.
69 return 10; // "r9"
70 }
71 break;
72 case 'w': // 10 strings to match.
73 switch (Name[1]) {
74 default: break;
75 case '0': // 1 string to match.
76 return 13; // "w0"
77 case '1': // 1 string to match.
78 return 14; // "w1"
79 case '2': // 1 string to match.
80 return 15; // "w2"
81 case '3': // 1 string to match.
82 return 16; // "w3"
83 case '4': // 1 string to match.
84 return 17; // "w4"
85 case '5': // 1 string to match.
86 return 18; // "w5"
87 case '6': // 1 string to match.
88 return 19; // "w6"
89 case '7': // 1 string to match.
90 return 20; // "w7"
91 case '8': // 1 string to match.
92 return 21; // "w8"
93 case '9': // 1 string to match.
94 return 22; // "w9"
95 }
96 break;
97 }
98 break;
99 case 3: // 4 strings to match.
100 switch (Name[0]) {
101 default: break;
102 case 'r': // 2 strings to match.
103 if (Name[1] != '1')
104 break;
105 switch (Name[2]) {
106 default: break;
107 case '0': // 1 string to match.
108 return 11; // "r10"
109 case '1': // 1 string to match.
110 return 12; // "r11"
111 }
112 break;
113 case 'w': // 2 strings to match.
114 if (Name[1] != '1')
115 break;
116 switch (Name[2]) {
117 default: break;
118 case '0': // 1 string to match.
119 return 23; // "w10"
120 case '1': // 1 string to match.
121 return 24; // "w11"
122 }
123 break;
124 }
125 break;
126 }
127 return 0;
128}
129
130#endif // GET_REGISTER_MATCHER
131
132
133#ifdef GET_SUBTARGET_FEATURE_NAME
134#undef GET_SUBTARGET_FEATURE_NAME
135
136// User-level names for subtarget features that participate in
137// instruction matching.
138static const char *getSubtargetFeatureName(uint64_t Val) {
139 return "(unknown)";
140}
141
142#endif // GET_SUBTARGET_FEATURE_NAME
143
144
145#ifdef GET_MATCHER_IMPLEMENTATION
146#undef GET_MATCHER_IMPLEMENTATION
147
148namespace {
149enum OperatorConversionKind {
150 CVT_Done,
151 CVT_Reg,
152 CVT_Tied,
153 CVT_95_Reg,
154 CVT_95_addImmOperands,
155 CVT_imm_95_0,
156 CVT_NUM_CONVERTERS
157};
158
159enum InstructionConversionKind {
160 Convert__Reg1_0__Reg1_2,
161 Convert__Reg1_0__Imm1_2,
162 Convert__Reg1_0__Tie0__Reg1_3,
163 Convert__Reg1_0__Tie0__Imm1_3,
164 Convert__Reg1_0__Tie0,
165 Convert__Reg1_0__Tie0__Reg1_4,
166 Convert__Reg1_0__Tie0__Imm1_4,
167 Convert__Reg1_0__Tie0__Reg1_5,
168 Convert__Reg1_0__Tie0__Imm1_5,
169 Convert__Reg1_0__Reg1_8__Imm1_9,
170 Convert__Imm1_2__Imm1_3,
171 Convert__Reg1_3__Reg1_5__Reg1_7__Imm1_6__Reg1_9__Reg1_11,
172 Convert__Reg1_3__Reg1_5__Imm1_7__Imm1_6__Reg1_9__Reg1_11,
173 Convert__Reg1_10__Reg1_6__Imm1_7,
174 Convert__Imm1_1,
175 Convert_NoOperands,
176 Convert__Reg1_1__Reg1_3__Imm1_5,
177 Convert__Reg1_1__Imm1_3__Imm1_5,
178 Convert__Reg1_1__Reg1_4__Imm1_6,
179 Convert__Reg1_1__Imm1_4__Imm1_6,
180 Convert__Reg1_1__Reg1_5__Imm1_7,
181 Convert__Reg1_1__Imm1_5__Imm1_7,
182 Convert__Reg1_1__Imm1_2__Imm1_3,
183 Convert__Reg1_1__Reg1_2__Imm1_3,
184 Convert__Reg1_12__Reg1_7__Imm1_8__Tie0,
185 Convert__imm_95_0__Reg1_9,
186 Convert__imm_95_0__Imm1_9,
187 CVT_NUM_SIGNATURES
188};
189
190} // end anonymous namespace
191
192static const uint8_t ConversionTable[CVT_NUM_SIGNATURES][13] = {
193 // Convert__Reg1_0__Reg1_2
194 { CVT_95_Reg, 0, CVT_95_Reg, 2, CVT_Done },
195 // Convert__Reg1_0__Imm1_2
196 { CVT_95_Reg, 0, CVT_95_addImmOperands, 2, CVT_Done },
197 // Convert__Reg1_0__Tie0__Reg1_3
198 { CVT_95_Reg, 0, CVT_Tied, 0, CVT_95_Reg, 3, CVT_Done },
199 // Convert__Reg1_0__Tie0__Imm1_3
200 { CVT_95_Reg, 0, CVT_Tied, 0, CVT_95_addImmOperands, 3, CVT_Done },
201 // Convert__Reg1_0__Tie0
202 { CVT_95_Reg, 0, CVT_Tied, 0, CVT_Done },
203 // Convert__Reg1_0__Tie0__Reg1_4
204 { CVT_95_Reg, 0, CVT_Tied, 0, CVT_95_Reg, 4, CVT_Done },
205 // Convert__Reg1_0__Tie0__Imm1_4
206 { CVT_95_Reg, 0, CVT_Tied, 0, CVT_95_addImmOperands, 4, CVT_Done },
207 // Convert__Reg1_0__Tie0__Reg1_5
208 { CVT_95_Reg, 0, CVT_Tied, 0, CVT_95_Reg, 5, CVT_Done },
209 // Convert__Reg1_0__Tie0__Imm1_5
210 { CVT_95_Reg, 0, CVT_Tied, 0, CVT_95_addImmOperands, 5, CVT_Done },
211 // Convert__Reg1_0__Reg1_8__Imm1_9
212 { CVT_95_Reg, 0, CVT_95_Reg, 8, CVT_95_addImmOperands, 9, CVT_Done },
213 // Convert__Imm1_2__Imm1_3
214 { CVT_95_addImmOperands, 2, CVT_95_addImmOperands, 3, CVT_Done },
215 // Convert__Reg1_3__Reg1_5__Reg1_7__Imm1_6__Reg1_9__Reg1_11
216 { CVT_95_Reg, 3, CVT_95_Reg, 5, CVT_95_Reg, 7, CVT_95_addImmOperands, 6, CVT_95_Reg, 9, CVT_95_Reg, 11, CVT_Done },
217 // Convert__Reg1_3__Reg1_5__Imm1_7__Imm1_6__Reg1_9__Reg1_11
218 { CVT_95_Reg, 3, CVT_95_Reg, 5, CVT_95_addImmOperands, 7, CVT_95_addImmOperands, 6, CVT_95_Reg, 9, CVT_95_Reg, 11, CVT_Done },
219 // Convert__Reg1_10__Reg1_6__Imm1_7
220 { CVT_95_Reg, 10, CVT_95_Reg, 6, CVT_95_addImmOperands, 7, CVT_Done },
221 // Convert__Imm1_1
222 { CVT_95_addImmOperands, 1, CVT_Done },
223 // Convert_NoOperands
224 { CVT_Done },
225 // Convert__Reg1_1__Reg1_3__Imm1_5
226 { CVT_95_Reg, 1, CVT_95_Reg, 3, CVT_95_addImmOperands, 5, CVT_Done },
227 // Convert__Reg1_1__Imm1_3__Imm1_5
228 { CVT_95_Reg, 1, CVT_95_addImmOperands, 3, CVT_95_addImmOperands, 5, CVT_Done },
229 // Convert__Reg1_1__Reg1_4__Imm1_6
230 { CVT_95_Reg, 1, CVT_95_Reg, 4, CVT_95_addImmOperands, 6, CVT_Done },
231 // Convert__Reg1_1__Imm1_4__Imm1_6
232 { CVT_95_Reg, 1, CVT_95_addImmOperands, 4, CVT_95_addImmOperands, 6, CVT_Done },
233 // Convert__Reg1_1__Reg1_5__Imm1_7
234 { CVT_95_Reg, 1, CVT_95_Reg, 5, CVT_95_addImmOperands, 7, CVT_Done },
235 // Convert__Reg1_1__Imm1_5__Imm1_7
236 { CVT_95_Reg, 1, CVT_95_addImmOperands, 5, CVT_95_addImmOperands, 7, CVT_Done },
237 // Convert__Reg1_1__Imm1_2__Imm1_3
238 { CVT_95_Reg, 1, CVT_95_addImmOperands, 2, CVT_95_addImmOperands, 3, CVT_Done },
239 // Convert__Reg1_1__Reg1_2__Imm1_3
240 { CVT_95_Reg, 1, CVT_95_Reg, 2, CVT_95_addImmOperands, 3, CVT_Done },
241 // Convert__Reg1_12__Reg1_7__Imm1_8__Tie0
242 { CVT_95_Reg, 12, CVT_95_Reg, 7, CVT_95_addImmOperands, 8, CVT_Tied, 0, CVT_Done },
243 // Convert__imm_95_0__Reg1_9
244 { CVT_imm_95_0, 0, CVT_95_Reg, 9, CVT_Done },
245 // Convert__imm_95_0__Imm1_9
246 { CVT_imm_95_0, 0, CVT_95_addImmOperands, 9, CVT_Done },
247};
248
249void BPFAsmParser::
250convertToMCInst(unsigned Kind, MCInst &Inst, unsigned Opcode,
251 const OperandVector &Operands) {
252 assert(Kind < CVT_NUM_SIGNATURES && "Invalid signature!")(static_cast <bool> (Kind < CVT_NUM_SIGNATURES &&
"Invalid signature!") ? void (0) : __assert_fail ("Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\""
, "/build/llvm-toolchain-snapshot-6.0~svn318693/build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc"
, 252, __extension__ __PRETTY_FUNCTION__))
;
253 const uint8_t *Converter = ConversionTable[Kind];
254 unsigned OpIdx;
255 Inst.setOpcode(Opcode);
256 for (const uint8_t *p = Converter; *p; p+= 2) {
257 OpIdx = *(p + 1);
258 switch (*p) {
259 default: llvm_unreachable("invalid conversion entry!")::llvm::llvm_unreachable_internal("invalid conversion entry!"
, "/build/llvm-toolchain-snapshot-6.0~svn318693/build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc"
, 259)
;
260 case CVT_Reg:
261 static_cast<BPFOperand&>(*Operands[OpIdx]).addRegOperands(Inst, 1);
262 break;
263 case CVT_Tied:
264 Inst.addOperand(Inst.getOperand(OpIdx));
265 break;
266 case CVT_95_Reg:
267 static_cast<BPFOperand&>(*Operands[OpIdx]).addRegOperands(Inst, 1);
268 break;
269 case CVT_95_addImmOperands:
270 static_cast<BPFOperand&>(*Operands[OpIdx]).addImmOperands(Inst, 1);
271 break;
272 case CVT_imm_95_0:
273 Inst.addOperand(MCOperand::createImm(0));
274 break;
275 }
276 }
277}
278
279void BPFAsmParser::
280convertToMapAndConstraints(unsigned Kind,
281 const OperandVector &Operands) {
282 assert(Kind < CVT_NUM_SIGNATURES && "Invalid signature!")(static_cast <bool> (Kind < CVT_NUM_SIGNATURES &&
"Invalid signature!") ? void (0) : __assert_fail ("Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\""
, "/build/llvm-toolchain-snapshot-6.0~svn318693/build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc"
, 282, __extension__ __PRETTY_FUNCTION__))
;
283 unsigned NumMCOperands = 0;
284 const uint8_t *Converter = ConversionTable[Kind];
285 for (const uint8_t *p = Converter; *p; p+= 2) {
286 switch (*p) {
287 default: llvm_unreachable("invalid conversion entry!")::llvm::llvm_unreachable_internal("invalid conversion entry!"
, "/build/llvm-toolchain-snapshot-6.0~svn318693/build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc"
, 287)
;
288 case CVT_Reg:
289 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
290 Operands[*(p + 1)]->setConstraint("r");
291 ++NumMCOperands;
292 break;
293 case CVT_Tied:
294 ++NumMCOperands;
295 break;
296 case CVT_95_Reg:
297 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
298 Operands[*(p + 1)]->setConstraint("r");
299 NumMCOperands += 1;
300 break;
301 case CVT_95_addImmOperands:
302 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
303 Operands[*(p + 1)]->setConstraint("m");
304 NumMCOperands += 1;
305 break;
306 case CVT_imm_95_0:
307 Operands[*(p + 1)]->setMCOperandNum(NumMCOperands);
308 Operands[*(p + 1)]->setConstraint("");
309 ++NumMCOperands;
310 break;
311 }
312 }
313}
314
315namespace {
316
317/// MatchClassKind - The kinds of classes which participate in
318/// instruction matching.
319enum MatchClassKind {
320 InvalidMatchClass = 0,
321 OptionalMatchClass = 1,
322 MCK__EXCLAIM_, // '!'
323 MCK__35_, // '#'
324 MCK__38_, // '&'
325 MCK__40_, // '('
326 MCK__41_, // ')'
327 MCK__STAR_, // '*'
328 MCK__43_, // '+'
329 MCK__MINUS_, // '-'
330 MCK__47_, // '/'
331 MCK__COLON_, // ':'
332 MCK__LT_, // '<'
333 MCK__61_, // '='
334 MCK__GT_, // '>'
335 MCK__63_, // '?'
336 MCK_ADJCALLSTACKDOWN, // 'ADJCALLSTACKDOWN'
337 MCK_ADJCALLSTACKUP, // 'ADJCALLSTACKUP'
338 MCK_PSEUDO, // 'PSEUDO'
339 MCK_Select, // 'Select'
340 MCK__91_, // '['
341 MCK__93_, // ']'
342 MCK__94_, // '^'
343 MCK_be16, // 'be16'
344 MCK_be32, // 'be32'
345 MCK_be64, // 'be64'
346 MCK_call, // 'call'
347 MCK_callx, // 'callx'
348 MCK_exit, // 'exit'
349 MCK_goto, // 'goto'
350 MCK_if, // 'if'
351 MCK_ld_95_pseudo, // 'ld_pseudo'
352 MCK_le16, // 'le16'
353 MCK_le32, // 'le32'
354 MCK_le64, // 'le64'
355 MCK_lea, // 'lea'
356 MCK_ll, // 'll'
357 MCK_lock, // 'lock'
358 MCK_nop, // 'nop'
359 MCK_s, // 's'
360 MCK_skb, // 'skb'
361 MCK_u16, // 'u16'
362 MCK_u32, // 'u32'
363 MCK_u64, // 'u64'
364 MCK_u8, // 'u8'
365 MCK__124_, // '|'
366 MCK_LAST_TOKEN = MCK__124_,
367 MCK_R0, // register class 'R0'
368 MCK_GPR, // register class 'GPR'
369 MCK_GPR32, // register class 'GPR32'
370 MCK_LAST_REGISTER = MCK_GPR32,
371 MCK_Imm, // user defined class 'ImmAsmOperand'
372 NumMatchClassKinds
373};
374
375}
376
377static unsigned getDiagKindFromRegisterClass(MatchClassKind RegisterClass) {
378 return MCTargetAsmParser::Match_InvalidOperand;
379}
380
381static MatchClassKind matchTokenString(StringRef Name) {
382 switch (Name.size()) {
383 default: break;
384 case 1: // 19 strings to match.
385 switch (Name[0]) {
386 default: break;
387 case '!': // 1 string to match.
388 return MCK__EXCLAIM_; // "!"
389 case '#': // 1 string to match.
390 return MCK__35_; // "#"
391 case '&': // 1 string to match.
392 return MCK__38_; // "&"
393 case '(': // 1 string to match.
394 return MCK__40_; // "("
395 case ')': // 1 string to match.
396 return MCK__41_; // ")"
397 case '*': // 1 string to match.
398 return MCK__STAR_; // "*"
399 case '+': // 1 string to match.
400 return MCK__43_; // "+"
401 case '-': // 1 string to match.
402 return MCK__MINUS_; // "-"
403 case '/': // 1 string to match.
404 return MCK__47_; // "/"
405 case ':': // 1 string to match.
406 return MCK__COLON_; // ":"
407 case '<': // 1 string to match.
408 return MCK__LT_; // "<"
409 case '=': // 1 string to match.
410 return MCK__61_; // "="
411 case '>': // 1 string to match.
412 return MCK__GT_; // ">"
413 case '?': // 1 string to match.
414 return MCK__63_; // "?"
415 case '[': // 1 string to match.
416 return MCK__91_; // "["
417 case ']': // 1 string to match.
418 return MCK__93_; // "]"
419 case '^': // 1 string to match.
420 return MCK__94_; // "^"
421 case 's': // 1 string to match.
422 return MCK_s; // "s"
423 case '|': // 1 string to match.
424 return MCK__124_; // "|"
425 }
426 break;
427 case 2: // 3 strings to match.
428 switch (Name[0]) {
429 default: break;
430 case 'i': // 1 string to match.
431 if (Name[1] != 'f')
432 break;
433 return MCK_if; // "if"
434 case 'l': // 1 string to match.
435 if (Name[1] != 'l')
436 break;
437 return MCK_ll; // "ll"
438 case 'u': // 1 string to match.
439 if (Name[1] != '8')
440 break;
441 return MCK_u8; // "u8"
442 }
443 break;
444 case 3: // 6 strings to match.
445 switch (Name[0]) {
446 default: break;
447 case 'l': // 1 string to match.
448 if (memcmp(Name.data()+1, "ea", 2) != 0)
449 break;
450 return MCK_lea; // "lea"
451 case 'n': // 1 string to match.
452 if (memcmp(Name.data()+1, "op", 2) != 0)
453 break;
454 return MCK_nop; // "nop"
455 case 's': // 1 string to match.
456 if (memcmp(Name.data()+1, "kb", 2) != 0)
457 break;
458 return MCK_skb; // "skb"
459 case 'u': // 3 strings to match.
460 switch (Name[1]) {
461 default: break;
462 case '1': // 1 string to match.
463 if (Name[2] != '6')
464 break;
465 return MCK_u16; // "u16"
466 case '3': // 1 string to match.
467 if (Name[2] != '2')
468 break;
469 return MCK_u32; // "u32"
470 case '6': // 1 string to match.
471 if (Name[2] != '4')
472 break;
473 return MCK_u64; // "u64"
474 }
475 break;
476 }
477 break;
478 case 4: // 10 strings to match.
479 switch (Name[0]) {
480 default: break;
481 case 'b': // 3 strings to match.
482 if (Name[1] != 'e')
483 break;
484 switch (Name[2]) {
485 default: break;
486 case '1': // 1 string to match.
487 if (Name[3] != '6')
488 break;
489 return MCK_be16; // "be16"
490 case '3': // 1 string to match.
491 if (Name[3] != '2')
492 break;
493 return MCK_be32; // "be32"
494 case '6': // 1 string to match.
495 if (Name[3] != '4')
496 break;
497 return MCK_be64; // "be64"
498 }
499 break;
500 case 'c': // 1 string to match.
501 if (memcmp(Name.data()+1, "all", 3) != 0)
502 break;
503 return MCK_call; // "call"
504 case 'e': // 1 string to match.
505 if (memcmp(Name.data()+1, "xit", 3) != 0)
506 break;
507 return MCK_exit; // "exit"
508 case 'g': // 1 string to match.
509 if (memcmp(Name.data()+1, "oto", 3) != 0)
510 break;
511 return MCK_goto; // "goto"
512 case 'l': // 4 strings to match.
513 switch (Name[1]) {
514 default: break;
515 case 'e': // 3 strings to match.
516 switch (Name[2]) {
517 default: break;
518 case '1': // 1 string to match.
519 if (Name[3] != '6')
520 break;
521 return MCK_le16; // "le16"
522 case '3': // 1 string to match.
523 if (Name[3] != '2')
524 break;
525 return MCK_le32; // "le32"
526 case '6': // 1 string to match.
527 if (Name[3] != '4')
528 break;
529 return MCK_le64; // "le64"
530 }
531 break;
532 case 'o': // 1 string to match.
533 if (memcmp(Name.data()+2, "ck", 2) != 0)
534 break;
535 return MCK_lock; // "lock"
536 }
537 break;
538 }
539 break;
540 case 5: // 1 string to match.
541 if (memcmp(Name.data()+0, "callx", 5) != 0)
542 break;
543 return MCK_callx; // "callx"
544 case 6: // 2 strings to match.
545 switch (Name[0]) {
546 default: break;
547 case 'P': // 1 string to match.
548 if (memcmp(Name.data()+1, "SEUDO", 5) != 0)
549 break;
550 return MCK_PSEUDO; // "PSEUDO"
551 case 'S': // 1 string to match.
552 if (memcmp(Name.data()+1, "elect", 5) != 0)
553 break;
554 return MCK_Select; // "Select"
555 }
556 break;
557 case 9: // 1 string to match.
558 if (memcmp(Name.data()+0, "ld_pseudo", 9) != 0)
559 break;
560 return MCK_ld_95_pseudo; // "ld_pseudo"
561 case 14: // 1 string to match.
562 if (memcmp(Name.data()+0, "ADJCALLSTACKUP", 14) != 0)
563 break;
564 return MCK_ADJCALLSTACKUP; // "ADJCALLSTACKUP"
565 case 16: // 1 string to match.
566 if (memcmp(Name.data()+0, "ADJCALLSTACKDOWN", 16) != 0)
567 break;
568 return MCK_ADJCALLSTACKDOWN; // "ADJCALLSTACKDOWN"
569 }
570 return InvalidMatchClass;
571}
572
573/// isSubclass - Compute whether \p A is a subclass of \p B.
574static bool isSubclass(MatchClassKind A, MatchClassKind B) {
575 if (A == B)
576 return true;
577
578 switch (A) {
579 default:
580 return false;
581
582 case MCK_R0:
583 return B == MCK_GPR;
584 }
585}
586
587static unsigned validateOperandClass(MCParsedAsmOperand &GOp, MatchClassKind Kind) {
588 BPFOperand &Operand = (BPFOperand&)GOp;
589 if (Kind == InvalidMatchClass)
590 return MCTargetAsmParser::Match_InvalidOperand;
591
592 if (Operand.isToken() && Kind <= MCK_LAST_TOKEN)
593 return isSubclass(matchTokenString(Operand.getToken()), Kind) ?
594 MCTargetAsmParser::Match_Success :
595 MCTargetAsmParser::Match_InvalidOperand;
596
597 switch (Kind) {
598 default: break;
599 // 'Imm' class
600 case MCK_Imm:
601 if (Operand.isImm())
602 return MCTargetAsmParser::Match_Success;
603 break;
604 } // end switch (Kind)
605
606 if (Operand.isReg()) {
607 MatchClassKind OpKind;
608 switch (Operand.getReg()) {
609 default: OpKind = InvalidMatchClass; break;
610 case BPF::W0: OpKind = MCK_GPR32; break;
611 case BPF::W1: OpKind = MCK_GPR32; break;
612 case BPF::W2: OpKind = MCK_GPR32; break;
613 case BPF::W3: OpKind = MCK_GPR32; break;
614 case BPF::W4: OpKind = MCK_GPR32; break;
615 case BPF::W5: OpKind = MCK_GPR32; break;
616 case BPF::W6: OpKind = MCK_GPR32; break;
617 case BPF::W7: OpKind = MCK_GPR32; break;
618 case BPF::W8: OpKind = MCK_GPR32; break;
619 case BPF::W9: OpKind = MCK_GPR32; break;
620 case BPF::W10: OpKind = MCK_GPR32; break;
621 case BPF::W11: OpKind = MCK_GPR32; break;
622 case BPF::R0: OpKind = MCK_R0; break;
623 case BPF::R1: OpKind = MCK_GPR; break;
624 case BPF::R2: OpKind = MCK_GPR; break;
625 case BPF::R3: OpKind = MCK_GPR; break;
626 case BPF::R4: OpKind = MCK_GPR; break;
627 case BPF::R5: OpKind = MCK_GPR; break;
628 case BPF::R6: OpKind = MCK_GPR; break;
629 case BPF::R7: OpKind = MCK_GPR; break;
630 case BPF::R8: OpKind = MCK_GPR; break;
631 case BPF::R9: OpKind = MCK_GPR; break;
632 case BPF::R10: OpKind = MCK_GPR; break;
633 case BPF::R11: OpKind = MCK_GPR; break;
634 }
635 return isSubclass(OpKind, Kind) ? (unsigned)MCTargetAsmParser::Match_Success :
636 getDiagKindFromRegisterClass(Kind);
637 }
638
639 if (Kind > MCK_LAST_TOKEN && Kind <= MCK_LAST_REGISTER)
640 return getDiagKindFromRegisterClass(Kind);
641
642 return MCTargetAsmParser::Match_InvalidOperand;
643}
644
645#ifndef NDEBUG
646const char *getMatchClassName(MatchClassKind Kind) {
647 switch (Kind) {
648 case InvalidMatchClass: return "InvalidMatchClass";
649 case OptionalMatchClass: return "OptionalMatchClass";
650 case MCK__EXCLAIM_: return "MCK__EXCLAIM_";
651 case MCK__35_: return "MCK__35_";
652 case MCK__38_: return "MCK__38_";
653 case MCK__40_: return "MCK__40_";
654 case MCK__41_: return "MCK__41_";
655 case MCK__STAR_: return "MCK__STAR_";
656 case MCK__43_: return "MCK__43_";
657 case MCK__MINUS_: return "MCK__MINUS_";
658 case MCK__47_: return "MCK__47_";
659 case MCK__COLON_: return "MCK__COLON_";
660 case MCK__LT_: return "MCK__LT_";
661 case MCK__61_: return "MCK__61_";
662 case MCK__GT_: return "MCK__GT_";
663 case MCK__63_: return "MCK__63_";
664 case MCK_ADJCALLSTACKDOWN: return "MCK_ADJCALLSTACKDOWN";
665 case MCK_ADJCALLSTACKUP: return "MCK_ADJCALLSTACKUP";
666 case MCK_PSEUDO: return "MCK_PSEUDO";
667 case MCK_Select: return "MCK_Select";
668 case MCK__91_: return "MCK__91_";
669 case MCK__93_: return "MCK__93_";
670 case MCK__94_: return "MCK__94_";
671 case MCK_be16: return "MCK_be16";
672 case MCK_be32: return "MCK_be32";
673 case MCK_be64: return "MCK_be64";
674 case MCK_call: return "MCK_call";
675 case MCK_callx: return "MCK_callx";
676 case MCK_exit: return "MCK_exit";
677 case MCK_goto: return "MCK_goto";
678 case MCK_if: return "MCK_if";
679 case MCK_ld_95_pseudo: return "MCK_ld_95_pseudo";
680 case MCK_le16: return "MCK_le16";
681 case MCK_le32: return "MCK_le32";
682 case MCK_le64: return "MCK_le64";
683 case MCK_lea: return "MCK_lea";
684 case MCK_ll: return "MCK_ll";
685 case MCK_lock: return "MCK_lock";
686 case MCK_nop: return "MCK_nop";
687 case MCK_s: return "MCK_s";
688 case MCK_skb: return "MCK_skb";
689 case MCK_u16: return "MCK_u16";
690 case MCK_u32: return "MCK_u32";
691 case MCK_u64: return "MCK_u64";
692 case MCK_u8: return "MCK_u8";
693 case MCK__124_: return "MCK__124_";
694 case MCK_R0: return "MCK_R0";
695 case MCK_GPR: return "MCK_GPR";
696 case MCK_GPR32: return "MCK_GPR32";
697 case MCK_Imm: return "MCK_Imm";
698 case NumMatchClassKinds: return "NumMatchClassKinds";
699 }
700 llvm_unreachable("unhandled MatchClassKind!")::llvm::llvm_unreachable_internal("unhandled MatchClassKind!"
, "/build/llvm-toolchain-snapshot-6.0~svn318693/build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc"
, 700)
;
701}
702
703#endif // NDEBUG
704uint64_t BPFAsmParser::
705ComputeAvailableFeatures(const FeatureBitset& FB) const {
706 uint64_t Features = 0;
707 return Features;
708}
709
710static const char *const MnemonicTable =
711 "\000\001#\001*\004call\005callx\004exit\004goto\002if\tld_pseudo\003lea"
712 "\004lock\003nop\002r0";
713
714namespace {
715 struct MatchEntry {
Excessive padding in 'struct (anonymous namespace)::MatchEntry' (2 padding bytes, where 0 is optimal). Optimal fields order: Opcode, Mnemonic, ConvertFn, RequiredFeatures, Classes, consider reordering the fields or adding explicit padding members
716 uint8_t Mnemonic;
717 uint16_t Opcode;
718 uint8_t ConvertFn;
719 uint8_t RequiredFeatures;
720 uint8_t Classes[13];
721 StringRef getMnemonic() const {
722 return StringRef(MnemonicTable + Mnemonic + 1,
723 MnemonicTable[Mnemonic]);
724 }
725 };
726
727 // Predicate for searching for an opcode.
728 struct LessOpcode {
729 bool operator()(const MatchEntry &LHS, StringRef RHS) {
730 return LHS.getMnemonic() < RHS;
731 }
732 bool operator()(StringRef LHS, const MatchEntry &RHS) {
733 return LHS < RHS.getMnemonic();
734 }
735 bool operator()(const MatchEntry &LHS, const MatchEntry &RHS) {
736 return LHS.getMnemonic() < RHS.getMnemonic();
737 }
738 };
739} // end anonymous namespace.
740
741static const MatchEntry MatchTable0[] = {
742 { 0 /* */, BPF::MOV_rr, Convert__Reg1_0__Reg1_2, 0, { MCK_GPR, MCK__61_, MCK_GPR }, },
743 { 0 /* */, BPF::MOV_ri, Convert__Reg1_0__Imm1_2, 0, { MCK_GPR, MCK__61_, MCK_Imm }, },
744 { 0 /* */, BPF::MOV_rr_32, Convert__Reg1_0__Reg1_2, 0, { MCK_GPR32, MCK__61_, MCK_GPR32 }, },
745 { 0 /* */, BPF::MOV_ri_32, Convert__Reg1_0__Imm1_2, 0, { MCK_GPR32, MCK__61_, MCK_Imm }, },
746 { 0 /* */, BPF::AND_rr, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR, MCK__38_, MCK__61_, MCK_GPR }, },
747 { 0 /* */, BPF::AND_ri, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR, MCK__38_, MCK__61_, MCK_Imm }, },
748 { 0 /* */, BPF::MUL_rr, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR, MCK__STAR_, MCK__61_, MCK_GPR }, },
749 { 0 /* */, BPF::MUL_ri, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR, MCK__STAR_, MCK__61_, MCK_Imm }, },
750 { 0 /* */, BPF::ADD_rr, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR, MCK__43_, MCK__61_, MCK_GPR }, },
751 { 0 /* */, BPF::ADD_ri, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR, MCK__43_, MCK__61_, MCK_Imm }, },
752 { 0 /* */, BPF::SUB_rr, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR, MCK__MINUS_, MCK__61_, MCK_GPR }, },
753 { 0 /* */, BPF::SUB_ri, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR, MCK__MINUS_, MCK__61_, MCK_Imm }, },
754 { 0 /* */, BPF::DIV_rr, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR, MCK__47_, MCK__61_, MCK_GPR }, },
755 { 0 /* */, BPF::DIV_ri, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR, MCK__47_, MCK__61_, MCK_Imm }, },
756 { 0 /* */, BPF::NEG_64, Convert__Reg1_0__Tie0, 0, { MCK_GPR, MCK__61_, MCK__MINUS_, MCK_GPR }, },
757 { 0 /* */, BPF::BE16, Convert__Reg1_0__Tie0, 0, { MCK_GPR, MCK__61_, MCK_be16, MCK_GPR }, },
758 { 0 /* */, BPF::BE32, Convert__Reg1_0__Tie0, 0, { MCK_GPR, MCK__61_, MCK_be32, MCK_GPR }, },
759 { 0 /* */, BPF::BE64, Convert__Reg1_0__Tie0, 0, { MCK_GPR, MCK__61_, MCK_be64, MCK_GPR }, },
760 { 0 /* */, BPF::LE16, Convert__Reg1_0__Tie0, 0, { MCK_GPR, MCK__61_, MCK_le16, MCK_GPR }, },
761 { 0 /* */, BPF::LE32, Convert__Reg1_0__Tie0, 0, { MCK_GPR, MCK__61_, MCK_le32, MCK_GPR }, },
762 { 0 /* */, BPF::LE64, Convert__Reg1_0__Tie0, 0, { MCK_GPR, MCK__61_, MCK_le64, MCK_GPR }, },
763 { 0 /* */, BPF::LD_imm64, Convert__Reg1_0__Imm1_2, 0, { MCK_GPR, MCK__61_, MCK_Imm, MCK_ll }, },
764 { 0 /* */, BPF::XOR_rr, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR, MCK__94_, MCK__61_, MCK_GPR }, },
765 { 0 /* */, BPF::XOR_ri, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR, MCK__94_, MCK__61_, MCK_Imm }, },
766 { 0 /* */, BPF::OR_rr, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR, MCK__124_, MCK__61_, MCK_GPR }, },
767 { 0 /* */, BPF::OR_ri, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR, MCK__124_, MCK__61_, MCK_Imm }, },
768 { 0 /* */, BPF::AND_rr_32, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR32, MCK__38_, MCK__61_, MCK_GPR32 }, },
769 { 0 /* */, BPF::AND_ri_32, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR32, MCK__38_, MCK__61_, MCK_Imm }, },
770 { 0 /* */, BPF::MUL_rr_32, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR32, MCK__STAR_, MCK__61_, MCK_GPR32 }, },
771 { 0 /* */, BPF::MUL_ri_32, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR32, MCK__STAR_, MCK__61_, MCK_Imm }, },
772 { 0 /* */, BPF::ADD_rr_32, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR32, MCK__43_, MCK__61_, MCK_GPR32 }, },
773 { 0 /* */, BPF::ADD_ri_32, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR32, MCK__43_, MCK__61_, MCK_Imm }, },
774 { 0 /* */, BPF::SUB_rr_32, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR32, MCK__MINUS_, MCK__61_, MCK_GPR32 }, },
775 { 0 /* */, BPF::SUB_ri_32, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR32, MCK__MINUS_, MCK__61_, MCK_Imm }, },
776 { 0 /* */, BPF::DIV_rr_32, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR32, MCK__47_, MCK__61_, MCK_GPR32 }, },
777 { 0 /* */, BPF::DIV_ri_32, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR32, MCK__47_, MCK__61_, MCK_Imm }, },
778 { 0 /* */, BPF::NEG_32, Convert__Reg1_0__Tie0, 0, { MCK_GPR32, MCK__61_, MCK__MINUS_, MCK_GPR32 }, },
779 { 0 /* */, BPF::XOR_rr_32, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR32, MCK__94_, MCK__61_, MCK_GPR32 }, },
780 { 0 /* */, BPF::XOR_ri_32, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR32, MCK__94_, MCK__61_, MCK_Imm }, },
781 { 0 /* */, BPF::OR_rr_32, Convert__Reg1_0__Tie0__Reg1_3, 0, { MCK_GPR32, MCK__124_, MCK__61_, MCK_GPR32 }, },
782 { 0 /* */, BPF::OR_ri_32, Convert__Reg1_0__Tie0__Imm1_3, 0, { MCK_GPR32, MCK__124_, MCK__61_, MCK_Imm }, },
783 { 0 /* */, BPF::SLL_rr, Convert__Reg1_0__Tie0__Reg1_4, 0, { MCK_GPR, MCK__LT_, MCK__LT_, MCK__61_, MCK_GPR }, },
784 { 0 /* */, BPF::SLL_ri, Convert__Reg1_0__Tie0__Imm1_4, 0, { MCK_GPR, MCK__LT_, MCK__LT_, MCK__61_, MCK_Imm }, },
785 { 0 /* */, BPF::SRL_rr, Convert__Reg1_0__Tie0__Reg1_4, 0, { MCK_GPR, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR }, },
786 { 0 /* */, BPF::SRL_ri, Convert__Reg1_0__Tie0__Imm1_4, 0, { MCK_GPR, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
787 { 0 /* */, BPF::SLL_rr_32, Convert__Reg1_0__Tie0__Reg1_4, 0, { MCK_GPR32, MCK__LT_, MCK__LT_, MCK__61_, MCK_GPR32 }, },
788 { 0 /* */, BPF::SLL_ri_32, Convert__Reg1_0__Tie0__Imm1_4, 0, { MCK_GPR32, MCK__LT_, MCK__LT_, MCK__61_, MCK_Imm }, },
789 { 0 /* */, BPF::SRL_rr_32, Convert__Reg1_0__Tie0__Reg1_4, 0, { MCK_GPR32, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR32 }, },
790 { 0 /* */, BPF::SRL_ri_32, Convert__Reg1_0__Tie0__Imm1_4, 0, { MCK_GPR32, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
791 { 0 /* */, BPF::SRA_rr, Convert__Reg1_0__Tie0__Reg1_5, 0, { MCK_GPR, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR }, },
792 { 0 /* */, BPF::SRA_ri, Convert__Reg1_0__Tie0__Imm1_5, 0, { MCK_GPR, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
793 { 0 /* */, BPF::SRA_rr_32, Convert__Reg1_0__Tie0__Reg1_5, 0, { MCK_GPR32, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_GPR32 }, },
794 { 0 /* */, BPF::SRA_ri_32, Convert__Reg1_0__Tie0__Imm1_5, 0, { MCK_GPR32, MCK_s, MCK__GT_, MCK__GT_, MCK__61_, MCK_Imm }, },
795 { 0 /* */, BPF::LDH, Convert__Reg1_0__Reg1_8__Imm1_9, 0, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_ }, },
796 { 0 /* */, BPF::LDW, Convert__Reg1_0__Reg1_8__Imm1_9, 0, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_ }, },
797 { 0 /* */, BPF::LDD, Convert__Reg1_0__Reg1_8__Imm1_9, 0, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_ }, },
798 { 0 /* */, BPF::LDB, Convert__Reg1_0__Reg1_8__Imm1_9, 0, { MCK_GPR, MCK__61_, MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_ }, },
799 { 1 /* # */, BPF::ADJCALLSTACKDOWN, Convert__Imm1_2__Imm1_3, 0, { MCK__35_, MCK_ADJCALLSTACKDOWN, MCK_Imm, MCK_Imm }, },
800 { 1 /* # */, BPF::ADJCALLSTACKUP, Convert__Imm1_2__Imm1_3, 0, { MCK__35_, MCK_ADJCALLSTACKUP, MCK_Imm, MCK_Imm }, },
801 { 1 /* # */, BPF::Select, Convert__Reg1_3__Reg1_5__Reg1_7__Imm1_6__Reg1_9__Reg1_11, 0, { MCK__35_, MCK_Select, MCK_PSEUDO, MCK_GPR, MCK__61_, MCK_GPR, MCK_Imm, MCK_GPR, MCK__63_, MCK_GPR, MCK__COLON_, MCK_GPR }, },
802 { 1 /* # */, BPF::Select_Ri, Convert__Reg1_3__Reg1_5__Imm1_7__Imm1_6__Reg1_9__Reg1_11, 0, { MCK__35_, MCK_Select, MCK_PSEUDO, MCK_GPR, MCK__61_, MCK_GPR, MCK_Imm, MCK_Imm, MCK__63_, MCK_GPR, MCK__COLON_, MCK_GPR }, },
803 { 3 /* * */, BPF::STH, Convert__Reg1_10__Reg1_6__Imm1_7, 0, { MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_, MCK__61_, MCK_GPR }, },
804 { 3 /* * */, BPF::STW, Convert__Reg1_10__Reg1_6__Imm1_7, 0, { MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_, MCK__61_, MCK_GPR }, },
805 { 3 /* * */, BPF::STD, Convert__Reg1_10__Reg1_6__Imm1_7, 0, { MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_, MCK__61_, MCK_GPR }, },
806 { 3 /* * */, BPF::STB, Convert__Reg1_10__Reg1_6__Imm1_7, 0, { MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_, MCK__61_, MCK_GPR }, },
807 { 5 /* call */, BPF::JAL, Convert__Imm1_1, 0, { MCK_call, MCK_Imm }, },
808 { 10 /* callx */, BPF::JALX, Convert__Imm1_1, 0, { MCK_callx, MCK_Imm }, },
809 { 16 /* exit */, BPF::RET, Convert_NoOperands, 0, { MCK_exit }, },
810 { 21 /* goto */, BPF::JMP, Convert__Imm1_1, 0, { MCK_goto, MCK_Imm }, },
811 { 26 /* if */, BPF::JULT_rr, Convert__Reg1_1__Reg1_3__Imm1_5, 0, { MCK_if, MCK_GPR, MCK__LT_, MCK_GPR, MCK_goto, MCK_Imm }, },
812 { 26 /* if */, BPF::JULT_ri, Convert__Reg1_1__Imm1_3__Imm1_5, 0, { MCK_if, MCK_GPR, MCK__LT_, MCK_Imm, MCK_goto, MCK_Imm }, },
813 { 26 /* if */, BPF::JUGT_rr, Convert__Reg1_1__Reg1_3__Imm1_5, 0, { MCK_if, MCK_GPR, MCK__GT_, MCK_GPR, MCK_goto, MCK_Imm }, },
814 { 26 /* if */, BPF::JUGT_ri, Convert__Reg1_1__Imm1_3__Imm1_5, 0, { MCK_if, MCK_GPR, MCK__GT_, MCK_Imm, MCK_goto, MCK_Imm }, },
815 { 26 /* if */, BPF::JNE_rr, Convert__Reg1_1__Reg1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__EXCLAIM_, MCK__61_, MCK_GPR, MCK_goto, MCK_Imm }, },
816 { 26 /* if */, BPF::JNE_ri, Convert__Reg1_1__Imm1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__EXCLAIM_, MCK__61_, MCK_Imm, MCK_goto, MCK_Imm }, },
817 { 26 /* if */, BPF::JULE_rr, Convert__Reg1_1__Reg1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__LT_, MCK__61_, MCK_GPR, MCK_goto, MCK_Imm }, },
818 { 26 /* if */, BPF::JULE_ri, Convert__Reg1_1__Imm1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__LT_, MCK__61_, MCK_Imm, MCK_goto, MCK_Imm }, },
819 { 26 /* if */, BPF::JEQ_rr, Convert__Reg1_1__Reg1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__61_, MCK__61_, MCK_GPR, MCK_goto, MCK_Imm }, },
820 { 26 /* if */, BPF::JEQ_ri, Convert__Reg1_1__Imm1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__61_, MCK__61_, MCK_Imm, MCK_goto, MCK_Imm }, },
821 { 26 /* if */, BPF::JUGE_rr, Convert__Reg1_1__Reg1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__GT_, MCK__61_, MCK_GPR, MCK_goto, MCK_Imm }, },
822 { 26 /* if */, BPF::JUGE_ri, Convert__Reg1_1__Imm1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK__GT_, MCK__61_, MCK_Imm, MCK_goto, MCK_Imm }, },
823 { 26 /* if */, BPF::JSLT_rr, Convert__Reg1_1__Reg1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK_GPR, MCK_goto, MCK_Imm }, },
824 { 26 /* if */, BPF::JSLT_ri, Convert__Reg1_1__Imm1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK_Imm, MCK_goto, MCK_Imm }, },
825 { 26 /* if */, BPF::JSGT_rr, Convert__Reg1_1__Reg1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK_GPR, MCK_goto, MCK_Imm }, },
826 { 26 /* if */, BPF::JSGT_ri, Convert__Reg1_1__Imm1_4__Imm1_6, 0, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK_Imm, MCK_goto, MCK_Imm }, },
827 { 26 /* if */, BPF::JSLE_rr, Convert__Reg1_1__Reg1_5__Imm1_7, 0, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK__61_, MCK_GPR, MCK_goto, MCK_Imm }, },
828 { 26 /* if */, BPF::JSLE_ri, Convert__Reg1_1__Imm1_5__Imm1_7, 0, { MCK_if, MCK_GPR, MCK_s, MCK__LT_, MCK__61_, MCK_Imm, MCK_goto, MCK_Imm }, },
829 { 26 /* if */, BPF::JSGE_rr, Convert__Reg1_1__Reg1_5__Imm1_7, 0, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK__61_, MCK_GPR, MCK_goto, MCK_Imm }, },
830 { 26 /* if */, BPF::JSGE_ri, Convert__Reg1_1__Imm1_5__Imm1_7, 0, { MCK_if, MCK_GPR, MCK_s, MCK__GT_, MCK__61_, MCK_Imm, MCK_goto, MCK_Imm }, },
831 { 29 /* ld_pseudo */, BPF::LD_pseudo, Convert__Reg1_1__Imm1_2__Imm1_3, 0, { MCK_ld_95_pseudo, MCK_GPR, MCK_Imm, MCK_Imm }, },
832 { 39 /* lea */, BPF::FI_ri, Convert__Reg1_1__Reg1_2__Imm1_3, 0, { MCK_lea, MCK_GPR, MCK_GPR, MCK_Imm }, },
833 { 43 /* lock */, BPF::XADD32, Convert__Reg1_12__Reg1_7__Imm1_8__Tie0, 0, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_, MCK__43_, MCK__61_, MCK_GPR }, },
834 { 43 /* lock */, BPF::XADD64, Convert__Reg1_12__Reg1_7__Imm1_8__Tie0, 0, { MCK_lock, MCK__STAR_, MCK__40_, MCK_u64, MCK__STAR_, MCK__41_, MCK__40_, MCK_GPR, MCK_Imm, MCK__41_, MCK__43_, MCK__61_, MCK_GPR }, },
835 { 48 /* nop */, BPF::NOP, Convert__Imm1_1, 0, { MCK_nop, MCK_Imm }, },
836 { 52 /* r0 */, BPF::LD_IND_H, Convert__imm_95_0__Reg1_9, 0, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_GPR, MCK__93_ }, },
837 { 52 /* r0 */, BPF::LD_ABS_H, Convert__imm_95_0__Imm1_9, 0, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u16, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_Imm, MCK__93_ }, },
838 { 52 /* r0 */, BPF::LD_IND_W, Convert__imm_95_0__Reg1_9, 0, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_GPR, MCK__93_ }, },
839 { 52 /* r0 */, BPF::LD_ABS_W, Convert__imm_95_0__Imm1_9, 0, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u32, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_Imm, MCK__93_ }, },
840 { 52 /* r0 */, BPF::LD_IND_B, Convert__imm_95_0__Reg1_9, 0, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_GPR, MCK__93_ }, },
841 { 52 /* r0 */, BPF::LD_ABS_B, Convert__imm_95_0__Imm1_9, 0, { MCK_R0, MCK__61_, MCK__STAR_, MCK__40_, MCK_u8, MCK__STAR_, MCK__41_, MCK_skb, MCK__91_, MCK_Imm, MCK__93_ }, },
842};
843
844#include "llvm/Support/Debug.h"
845#include "llvm/Support/Format.h"
846
847unsigned BPFAsmParser::
848MatchInstructionImpl(const OperandVector &Operands,
849 MCInst &Inst,
850 uint64_t &ErrorInfo,
851 bool matchingInlineAsm, unsigned VariantID) {
852 // Eliminate obvious mismatches.
853 if (Operands.size() > 13) {
854 ErrorInfo = 13;
855 return Match_InvalidOperand;
856 }
857
858 // Get the current feature set.
859 uint64_t AvailableFeatures = getAvailableFeatures();
860
861 // Get the instruction mnemonic, which is the first token.
862 StringRef Mnemonic;
863 if (Operands[0]->isToken())
864 Mnemonic = ((BPFOperand&)*Operands[0]).getToken();
865
866 // Some state to try to produce better error messages.
867 bool HadMatchOtherThanFeatures = false;
868 bool HadMatchOtherThanPredicate = false;
869 unsigned RetCode = Match_InvalidOperand;
870 uint64_t MissingFeatures = ~0ULL;
871 // Set ErrorInfo to the operand that mismatches if it is
872 // wrong for all instances of the instruction.
873 ErrorInfo = ~0ULL;
874 // Find the appropriate table for this asm variant.
875 const MatchEntry *Start, *End;
876 switch (VariantID) {
877 default: llvm_unreachable("invalid variant!")::llvm::llvm_unreachable_internal("invalid variant!", "/build/llvm-toolchain-snapshot-6.0~svn318693/build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc"
, 877)
;
878 case 0: Start = std::begin(MatchTable0); End = std::end(MatchTable0); break;
879 }
880 // Search the table.
881 auto MnemonicRange = std::make_pair(Start, End);
882 unsigned SIndex = Mnemonic.empty() ? 0 : 1;
883 if (!Mnemonic.empty())
884 MnemonicRange = std::equal_range(Start, End, Mnemonic.lower(), LessOpcode());
885
886 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "AsmMatcher: found " <<do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "AsmMatcher: found " <<
std::distance(MnemonicRange.first, MnemonicRange.second) <<
" encodings with mnemonic '" << Mnemonic << "'\n"
; } } while (false)
887 std::distance(MnemonicRange.first, MnemonicRange.second) <<do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "AsmMatcher: found " <<
std::distance(MnemonicRange.first, MnemonicRange.second) <<
" encodings with mnemonic '" << Mnemonic << "'\n"
; } } while (false)
888 " encodings with mnemonic '" << Mnemonic << "'\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "AsmMatcher: found " <<
std::distance(MnemonicRange.first, MnemonicRange.second) <<
" encodings with mnemonic '" << Mnemonic << "'\n"
; } } while (false)
;
889
890 // Return a more specific error code if no mnemonics match.
891 if (MnemonicRange.first == MnemonicRange.second)
892 return Match_MnemonicFail;
893
894 for (const MatchEntry *it = MnemonicRange.first, *ie = MnemonicRange.second;
895 it != ie; ++it) {
896 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "Trying to match opcode "do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Trying to match opcode " <<
MII.getName(it->Opcode) << "\n"; } } while (false)
897 << MII.getName(it->Opcode) << "\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Trying to match opcode " <<
MII.getName(it->Opcode) << "\n"; } } while (false)
;
898 bool OperandsValid = true;
899 for (unsigned FormalIdx = SIndex, ActualIdx = SIndex; FormalIdx != 13; ++FormalIdx) {
900 auto Formal = static_cast<MatchClassKind>(it->Classes[FormalIdx]);
901 DEBUG_WITH_TYPE("asm-matcher",do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << " Matching formal operand class "
<< getMatchClassName(Formal) << " against actual operand at index "
<< ActualIdx; } } while (false)
902 dbgs() << " Matching formal operand class " << getMatchClassName(Formal)do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << " Matching formal operand class "
<< getMatchClassName(Formal) << " against actual operand at index "
<< ActualIdx; } } while (false)
903 << " against actual operand at index " << ActualIdx)do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << " Matching formal operand class "
<< getMatchClassName(Formal) << " against actual operand at index "
<< ActualIdx; } } while (false)
;
904 if (ActualIdx < Operands.size())
905 DEBUG_WITH_TYPE("asm-matcher", dbgs() << " (";do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << " ("; Operands[ActualIdx]->
print(dbgs()); dbgs() << "): "; } } while (false)
906 Operands[ActualIdx]->print(dbgs()); dbgs() << "): ")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << " ("; Operands[ActualIdx]->
print(dbgs()); dbgs() << "): "; } } while (false)
;
907 else
908 DEBUG_WITH_TYPE("asm-matcher", dbgs() << ": ")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << ": "; } } while (false)
;
909 if (ActualIdx >= Operands.size()) {
910 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "actual operand index out of range ")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "actual operand index out of range "
; } } while (false)
;
911 OperandsValid = (Formal == InvalidMatchClass) || isSubclass(Formal, OptionalMatchClass);
912 if (!OperandsValid) ErrorInfo = ActualIdx;
913 break;
914 }
915 MCParsedAsmOperand &Actual = *Operands[ActualIdx];
916 unsigned Diag = validateOperandClass(Actual, Formal);
917 if (Diag == Match_Success) {
918 DEBUG_WITH_TYPE("asm-matcher",do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "match success using generic matcher\n"
; } } while (false)
919 dbgs() << "match success using generic matcher\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "match success using generic matcher\n"
; } } while (false)
;
920 ++ActualIdx;
921 continue;
922 }
923 // If the generic handler indicates an invalid operand
924 // failure, check for a special case.
925 if (Diag != Match_Success) {
926 unsigned TargetDiag = validateTargetOperandClass(Actual, Formal);
927 if (TargetDiag == Match_Success) {
928 DEBUG_WITH_TYPE("asm-matcher",do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "match success using target matcher\n"
; } } while (false)
929 dbgs() << "match success using target matcher\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "match success using target matcher\n"
; } } while (false)
;
930 ++ActualIdx;
931 continue;
932 }
933 // If the target matcher returned a specific error code use
934 // that, else use the one from the generic matcher.
935 if (TargetDiag != Match_InvalidOperand)
936 Diag = TargetDiag;
937 }
938 // If current formal operand wasn't matched and it is optional
939 // then try to match next formal operand
940 if (Diag == Match_InvalidOperand && isSubclass(Formal, OptionalMatchClass)) {
941 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "ignoring optional operand\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "ignoring optional operand\n"
; } } while (false)
;
942 continue;
943 }
944 // If this operand is broken for all of the instances of this
945 // mnemonic, keep track of it so we can report loc info.
946 // If we already had a match that only failed due to a
947 // target predicate, that diagnostic is preferred.
948 if (!HadMatchOtherThanPredicate &&
949 (it == MnemonicRange.first || ErrorInfo <= ActualIdx)) {
950 ErrorInfo = ActualIdx;
951 // InvalidOperand is the default. Prefer specificity.
952 if (Diag != Match_InvalidOperand)
953 RetCode = Diag;
954 }
955 // Otherwise, just reject this instance of the mnemonic.
956 OperandsValid = false;
957 break;
958 }
959
960 if (!OperandsValid) {
961 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "Opcode result: multiple "do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Opcode result: multiple "
"operand mismatches, ignoring " "this opcode\n"; } } while (
false)
962 "operand mismatches, ignoring "do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Opcode result: multiple "
"operand mismatches, ignoring " "this opcode\n"; } } while (
false)
963 "this opcode\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Opcode result: multiple "
"operand mismatches, ignoring " "this opcode\n"; } } while (
false)
;
964 continue;
965 }
966 if ((AvailableFeatures & it->RequiredFeatures) != it->RequiredFeatures) {
967 HadMatchOtherThanFeatures = true;
968 uint64_t NewMissingFeatures = it->RequiredFeatures & ~AvailableFeatures;
969 DEBUG_WITH_TYPE("asm-matcher", dbgs() << "Missing target features: "do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Missing target features: "
<< format_hex(NewMissingFeatures, 18) << "\n"; }
} while (false)
970 << format_hex(NewMissingFeatures, 18)do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Missing target features: "
<< format_hex(NewMissingFeatures, 18) << "\n"; }
} while (false)
971 << "\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Missing target features: "
<< format_hex(NewMissingFeatures, 18) << "\n"; }
} while (false)
;
972 if (countPopulation(NewMissingFeatures) <=
973 countPopulation(MissingFeatures))
974 MissingFeatures = NewMissingFeatures;
975 continue;
976 }
977
978 Inst.clear();
979
980 Inst.setOpcode(it->Opcode);
981 // We have a potential match but have not rendered the operands.
982 // Check the target predicate to handle any context sensitive
983 // constraints.
984 // For example, Ties that are referenced multiple times must be
985 // checked here to ensure the input is the same for each match
986 // constraints. If we leave it any later the ties will have been
987 // canonicalized
988 unsigned MatchResult;
989 if ((MatchResult = checkEarlyTargetMatchPredicate(Inst, Operands)) != Match_Success) {
990 Inst.clear();
991 DEBUG_WITH_TYPE(do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Early target match predicate failed with diag code "
<< MatchResult << "\n"; } } while (false)
992 "asm-matcher",do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Early target match predicate failed with diag code "
<< MatchResult << "\n"; } } while (false)
993 dbgs() << "Early target match predicate failed with diag code "do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Early target match predicate failed with diag code "
<< MatchResult << "\n"; } } while (false)
994 << MatchResult << "\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Early target match predicate failed with diag code "
<< MatchResult << "\n"; } } while (false)
;
995 RetCode = MatchResult;
996 HadMatchOtherThanPredicate = true;
997 continue;
998 }
999
1000 if (matchingInlineAsm) {
1001 convertToMapAndConstraints(it->ConvertFn, Operands);
1002 return Match_Success;
1003 }
1004
1005 // We have selected a definite instruction, convert the parsed
1006 // operands into the appropriate MCInst.
1007 convertToMCInst(it->ConvertFn, Inst, it->Opcode, Operands);
1008
1009 // We have a potential match. Check the target predicate to
1010 // handle any context sensitive constraints.
1011 if ((MatchResult = checkTargetMatchPredicate(Inst)) != Match_Success) {
1012 DEBUG_WITH_TYPE("asm-matcher",do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Target match predicate failed with diag code "
<< MatchResult << "\n"; } } while (false)
1013 dbgs() << "Target match predicate failed with diag code "do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Target match predicate failed with diag code "
<< MatchResult << "\n"; } } while (false)
1014 << MatchResult << "\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Target match predicate failed with diag code "
<< MatchResult << "\n"; } } while (false)
;
1015 Inst.clear();
1016 RetCode = MatchResult;
1017 HadMatchOtherThanPredicate = true;
1018 continue;
1019 }
1020
1021 DEBUG_WITH_TYPE(do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Opcode result: complete match, selecting this opcode\n"
; } } while (false)
1022 "asm-matcher",do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Opcode result: complete match, selecting this opcode\n"
; } } while (false)
1023 dbgs() << "Opcode result: complete match, selecting this opcode\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("asm-matcher")) { dbgs() << "Opcode result: complete match, selecting this opcode\n"
; } } while (false)
;
1024 return Match_Success;
1025 }
1026
1027 // Okay, we had no match. Try to return a useful error code.
1028 if (HadMatchOtherThanPredicate || !HadMatchOtherThanFeatures)
1029 return RetCode;
1030
1031 // Missing feature matches return which features were missing
1032 ErrorInfo = MissingFeatures;
1033 return Match_MissingFeature;
1034}
1035
1036#endif // GET_MATCHER_IMPLEMENTATION
1037
1038
1039#ifdef GET_MNEMONIC_SPELL_CHECKER
1040#undef GET_MNEMONIC_SPELL_CHECKER
1041
1042static std::string BPFMnemonicSpellCheck(StringRef S, uint64_t FBS, unsigned VariantID) {
1043 const unsigned MaxEditDist = 2;
1044 std::vector<StringRef> Candidates;
1045 StringRef Prev = "";
1046
1047 // Find the appropriate table for this asm variant.
1048 const MatchEntry *Start, *End;
1049 switch (VariantID) {
1050 default: llvm_unreachable("invalid variant!")::llvm::llvm_unreachable_internal("invalid variant!", "/build/llvm-toolchain-snapshot-6.0~svn318693/build-llvm/lib/Target/BPF/BPFGenAsmMatcher.inc"
, 1050)
;
1051 case 0: Start = std::begin(MatchTable0); End = std::end(MatchTable0); break;
1052 }
1053
1054 for (auto I = Start; I < End; I++) {
1055 // Ignore unsupported instructions.
1056 if ((FBS & I->RequiredFeatures) != I->RequiredFeatures)
1057 continue;
1058
1059 StringRef T = I->getMnemonic();
1060 // Avoid recomputing the edit distance for the same string.
1061 if (T.equals(Prev))
1062 continue;
1063
1064 Prev = T;
1065 unsigned Dist = S.edit_distance(T, false, MaxEditDist);
1066 if (Dist <= MaxEditDist)
1067 Candidates.push_back(T);
1068 }
1069
1070 if (Candidates.empty())
1071 return "";
1072
1073 std::string Res = ", did you mean: ";
1074 unsigned i = 0;
1075 for( ; i < Candidates.size() - 1; i++)
1076 Res += Candidates[i].str() + ", ";
1077 return Res + Candidates[i].str() + "?";
1078}
1079
1080#endif // GET_MNEMONIC_SPELL_CHECKER
1081