Coverage Report

Created: 2018-09-23 22:08

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/lib/Target/BPF/BPFGenMCCodeEmitter.inc
Line
Count
Source (jump to first uncovered line)
1
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
|*                                                                            *|
3
|* Machine Code Emitter                                                       *|
4
|*                                                                            *|
5
|* Automatically generated file, do not edit!                                 *|
6
|*                                                                            *|
7
\*===----------------------------------------------------------------------===*/
8
9
uint64_t BPFMCCodeEmitter::getBinaryCodeForInstr(const MCInst &MI,
10
    SmallVectorImpl<MCFixup> &Fixups,
11
868
    const MCSubtargetInfo &STI) const {
12
868
  static const uint64_t InstBits[] = {
13
868
    UINT64_C(0),
14
868
    UINT64_C(0),
15
868
    UINT64_C(0),
16
868
    UINT64_C(0),
17
868
    UINT64_C(0),
18
868
    UINT64_C(0),
19
868
    UINT64_C(0),
20
868
    UINT64_C(0),
21
868
    UINT64_C(0),
22
868
    UINT64_C(0),
23
868
    UINT64_C(0),
24
868
    UINT64_C(0),
25
868
    UINT64_C(0),
26
868
    UINT64_C(0),
27
868
    UINT64_C(0),
28
868
    UINT64_C(0),
29
868
    UINT64_C(0),
30
868
    UINT64_C(0),
31
868
    UINT64_C(0),
32
868
    UINT64_C(0),
33
868
    UINT64_C(0),
34
868
    UINT64_C(0),
35
868
    UINT64_C(0),
36
868
    UINT64_C(0),
37
868
    UINT64_C(0),
38
868
    UINT64_C(0),
39
868
    UINT64_C(0),
40
868
    UINT64_C(0),
41
868
    UINT64_C(0),
42
868
    UINT64_C(0),
43
868
    UINT64_C(0),
44
868
    UINT64_C(0),
45
868
    UINT64_C(0),
46
868
    UINT64_C(0),
47
868
    UINT64_C(0),
48
868
    UINT64_C(0),
49
868
    UINT64_C(0),
50
868
    UINT64_C(0),
51
868
    UINT64_C(0),
52
868
    UINT64_C(0),
53
868
    UINT64_C(0),
54
868
    UINT64_C(0),
55
868
    UINT64_C(0),
56
868
    UINT64_C(0),
57
868
    UINT64_C(0),
58
868
    UINT64_C(0),
59
868
    UINT64_C(0),
60
868
    UINT64_C(0),
61
868
    UINT64_C(0),
62
868
    UINT64_C(0),
63
868
    UINT64_C(0),
64
868
    UINT64_C(0),
65
868
    UINT64_C(0),
66
868
    UINT64_C(0),
67
868
    UINT64_C(0),
68
868
    UINT64_C(0),
69
868
    UINT64_C(0),
70
868
    UINT64_C(0),
71
868
    UINT64_C(0),
72
868
    UINT64_C(0),
73
868
    UINT64_C(0),
74
868
    UINT64_C(0),
75
868
    UINT64_C(0),
76
868
    UINT64_C(0),
77
868
    UINT64_C(0),
78
868
    UINT64_C(0),
79
868
    UINT64_C(0),
80
868
    UINT64_C(0),
81
868
    UINT64_C(0),
82
868
    UINT64_C(0),
83
868
    UINT64_C(0),
84
868
    UINT64_C(0),
85
868
    UINT64_C(0),
86
868
    UINT64_C(0),
87
868
    UINT64_C(0),
88
868
    UINT64_C(0),
89
868
    UINT64_C(0),
90
868
    UINT64_C(0),
91
868
    UINT64_C(0),
92
868
    UINT64_C(0),
93
868
    UINT64_C(0),
94
868
    UINT64_C(0),
95
868
    UINT64_C(0),
96
868
    UINT64_C(0),
97
868
    UINT64_C(0),
98
868
    UINT64_C(0),
99
868
    UINT64_C(0),
100
868
    UINT64_C(0),
101
868
    UINT64_C(0),
102
868
    UINT64_C(0),
103
868
    UINT64_C(0),
104
868
    UINT64_C(0),
105
868
    UINT64_C(0),
106
868
    UINT64_C(0),
107
868
    UINT64_C(0),
108
868
    UINT64_C(0),
109
868
    UINT64_C(0),
110
868
    UINT64_C(0),
111
868
    UINT64_C(0),
112
868
    UINT64_C(0),
113
868
    UINT64_C(0),
114
868
    UINT64_C(0),
115
868
    UINT64_C(0),
116
868
    UINT64_C(0),
117
868
    UINT64_C(0),
118
868
    UINT64_C(0),
119
868
    UINT64_C(0),
120
868
    UINT64_C(0),
121
868
    UINT64_C(0),
122
868
    UINT64_C(0),
123
868
    UINT64_C(0),
124
868
    UINT64_C(0),
125
868
    UINT64_C(0),
126
868
    UINT64_C(0),
127
868
    UINT64_C(0),
128
868
    UINT64_C(0),
129
868
    UINT64_C(0),
130
868
    UINT64_C(0),
131
868
    UINT64_C(0),
132
868
    UINT64_C(0),
133
868
    UINT64_C(0),
134
868
    UINT64_C(0),
135
868
    UINT64_C(0),
136
868
    UINT64_C(0),
137
868
    UINT64_C(0),
138
868
    UINT64_C(0),
139
868
    UINT64_C(0),
140
868
    UINT64_C(0),
141
868
    UINT64_C(0),
142
868
    UINT64_C(0),
143
868
    UINT64_C(0),
144
868
    UINT64_C(0),
145
868
    UINT64_C(0),
146
868
    UINT64_C(0),
147
868
    UINT64_C(0),
148
868
    UINT64_C(0),
149
868
    UINT64_C(0),
150
868
    UINT64_C(0),
151
868
    UINT64_C(0),
152
868
    UINT64_C(0),
153
868
    UINT64_C(0),
154
868
    UINT64_C(0),
155
868
    UINT64_C(0),
156
868
    UINT64_C(0),
157
868
    UINT64_C(0),
158
868
    UINT64_C(0),
159
868
    UINT64_C(0),
160
868
    UINT64_C(0),
161
868
    UINT64_C(504403158265495552), // ADD_ri
162
868
    UINT64_C(288230376151711744), // ADD_ri_32
163
868
    UINT64_C(1080863910568919040),  // ADD_rr
164
868
    UINT64_C(864691128455135232), // ADD_rr_32
165
868
    UINT64_C(6269010681299730432),  // AND_ri
166
868
    UINT64_C(6052837899185946624),  // AND_ri_32
167
868
    UINT64_C(6845471433603153920),  // AND_rr
168
868
    UINT64_C(6629298651489370112),  // AND_rr_32
169
868
    UINT64_C(15852670688344145936), // BE16
170
868
    UINT64_C(15852670688344145952), // BE32
171
868
    UINT64_C(15852670688344145984), // BE64
172
868
    UINT64_C(3963167672086036480),  // DIV_ri
173
868
    UINT64_C(3746994889972252672),  // DIV_ri_32
174
868
    UINT64_C(4539628424389459968),  // DIV_rr
175
868
    UINT64_C(4323455642275676160),  // DIV_rr_32
176
868
    UINT64_C(1738389456165011456),  // FI_ri
177
868
    UINT64_C(9583660007044415488),  // JAL
178
868
    UINT64_C(10160120759347838976), // JALX
179
868
    UINT64_C(1513209474796486656),  // JEQ_ri
180
868
    UINT64_C(2089670227099910144),  // JEQ_rr
181
868
    UINT64_C(360287970189639680), // JMP
182
868
    UINT64_C(6124895493223874560),  // JNE_ri
183
868
    UINT64_C(6701356245527298048),  // JNE_rr
184
868
    UINT64_C(8430738502437568512),  // JSGE_ri
185
868
    UINT64_C(9007199254740992000),  // JSGE_rr
186
868
    UINT64_C(7277816997830721536),  // JSGT_ri
187
868
    UINT64_C(7854277750134145024),  // JSGT_rr
188
868
    UINT64_C(15348267530078650368), // JSLE_ri
189
868
    UINT64_C(15924728282382073856), // JSLE_rr
190
868
    UINT64_C(14195346025471803392), // JSLT_ri
191
868
    UINT64_C(14771806777775226880), // JSLT_rr
192
868
    UINT64_C(3819052484010180608),  // JUGE_ri
193
868
    UINT64_C(4395513236313604096),  // JUGE_rr
194
868
    UINT64_C(2666130979403333632),  // JUGT_ri
195
868
    UINT64_C(3242591731706757120),  // JUGT_rr
196
868
    UINT64_C(13042424520864956416), // JULE_ri
197
868
    UINT64_C(13618885273168379904), // JULE_rr
198
868
    UINT64_C(11889503016258109440), // JULT_ri
199
868
    UINT64_C(12465963768561532928), // JULT_rr
200
868
    UINT64_C(8142508126285856768),  // LDB
201
868
    UINT64_C(8142508126285856768),  // LDB32
202
868
    UINT64_C(8718968878589280256),  // LDD
203
868
    UINT64_C(7566047373982433280),  // LDH
204
868
    UINT64_C(7566047373982433280),  // LDH32
205
868
    UINT64_C(6989586621679009792),  // LDW
206
868
    UINT64_C(6989586621679009792),  // LDW32
207
868
    UINT64_C(3458764513820540928),  // LD_ABS_B
208
868
    UINT64_C(2882303761517117440),  // LD_ABS_H
209
868
    UINT64_C(2305843009213693952),  // LD_ABS_W
210
868
    UINT64_C(5764607523034234880),  // LD_IND_B
211
868
    UINT64_C(5188146770730811392),  // LD_IND_H
212
868
    UINT64_C(4611686018427387904),  // LD_IND_W
213
868
    UINT64_C(1729382256910270464),  // LD_imm64
214
868
    UINT64_C(1729382256910270464),  // LD_pseudo
215
868
    UINT64_C(15276209936040722448), // LE16
216
868
    UINT64_C(15276209936040722464), // LE32
217
868
    UINT64_C(15276209936040722496), // LE64
218
868
    UINT64_C(13546827679130451968), // MOV_32_64
219
868
    UINT64_C(13186539708940812288), // MOV_ri
220
868
    UINT64_C(12970366926827028480), // MOV_ri_32
221
868
    UINT64_C(13763000461244235776), // MOV_rr
222
868
    UINT64_C(13546827679130451968), // MOV_rr_32
223
868
    UINT64_C(2810246167479189504),  // MUL_ri
224
868
    UINT64_C(2594073385365405696),  // MUL_ri_32
225
868
    UINT64_C(3386706919782612992),  // MUL_rr
226
868
    UINT64_C(3170534137668829184),  // MUL_rr_32
227
868
    UINT64_C(9511602413006487552),  // NEG_32
228
868
    UINT64_C(9727775195120271360),  // NEG_64
229
868
    UINT64_C(13763000461244235776), // NOP
230
868
    UINT64_C(5116089176692883456),  // OR_ri
231
868
    UINT64_C(4899916394579099648),  // OR_ri_32
232
868
    UINT64_C(5692549928996306944),  // OR_rr
233
868
    UINT64_C(5476377146882523136),  // OR_rr_32
234
868
    UINT64_C(10736581511651262464), // RET
235
868
    UINT64_C(7421932185906577408),  // SLL_ri
236
868
    UINT64_C(7205759403792793600),  // SLL_ri_32
237
868
    UINT64_C(7998392938210000896),  // SLL_rr
238
868
    UINT64_C(7782220156096217088),  // SLL_rr_32
239
868
    UINT64_C(14339461213547659264), // SRA_ri
240
868
    UINT64_C(14123288431433875456), // SRA_ri_32
241
868
    UINT64_C(14915921965851082752), // SRA_rr
242
868
    UINT64_C(14699749183737298944), // SRA_rr_32
243
868
    UINT64_C(8574853690513424384),  // SRL_ri
244
868
    UINT64_C(8358680908399640576),  // SRL_ri_32
245
868
    UINT64_C(9151314442816847872),  // SRL_rr
246
868
    UINT64_C(8935141660703064064),  // SRL_rr_32
247
868
    UINT64_C(8286623314361712640),  // STB
248
868
    UINT64_C(8286623314361712640),  // STB32
249
868
    UINT64_C(8863084066665136128),  // STD
250
868
    UINT64_C(7710162562058289152),  // STH
251
868
    UINT64_C(7710162562058289152),  // STH32
252
868
    UINT64_C(7133701809754865664),  // STW
253
868
    UINT64_C(7133701809754865664),  // STW32
254
868
    UINT64_C(1657324662872342528),  // SUB_ri
255
868
    UINT64_C(1441151880758558720),  // SUB_ri_32
256
868
    UINT64_C(2233785415175766016),  // SUB_rr
257
868
    UINT64_C(2017612633061982208),  // SUB_rr_32
258
868
    UINT64_C(14051230837395947520), // XADD32
259
868
    UINT64_C(15780613094306217984), // XADD64
260
868
    UINT64_C(12033618204333965312), // XOR_ri
261
868
    UINT64_C(11817445422220181504), // XOR_ri_32
262
868
    UINT64_C(12610078956637388800), // XOR_rr
263
868
    UINT64_C(12393906174523604992), // XOR_rr_32
264
868
    UINT64_C(0)
265
868
  };
266
868
  const unsigned opcode = MI.getOpcode();
267
868
  uint64_t Value = InstBits[opcode];
268
868
  uint64_t op = 0;
269
868
  (void)op;  // suppress warning
270
868
  switch (opcode) {
271
868
    case BPF::FI_ri:
272
70
    case BPF::NOP:
273
70
    case BPF::RET: {
274
70
      break;
275
70
    }
276
70
    case BPF::JMP: {
277
12
      // op: BrDst
278
12
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
279
12
      Value |= (op & UINT64_C(65535)) << 32;
280
12
      break;
281
70
    }
282
70
    case BPF::JAL:
283
24
    case BPF::JALX: {
284
24
      // op: BrDst
285
24
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
286
24
      Value |= op & UINT64_C(4294967295);
287
24
      break;
288
24
    }
289
24
    case BPF::BE16:
290
17
    case BPF::BE32:
291
17
    case BPF::BE64:
292
17
    case BPF::LE16:
293
17
    case BPF::LE32:
294
17
    case BPF::LE64:
295
17
    case BPF::NEG_32:
296
17
    case BPF::NEG_64: {
297
17
      // op: dst
298
17
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
299
17
      Value |= (op & UINT64_C(15)) << 48;
300
17
      break;
301
17
    }
302
38
    case BPF::JEQ_ri:
303
38
    case BPF::JNE_ri:
304
38
    case BPF::JSGE_ri:
305
38
    case BPF::JSGT_ri:
306
38
    case BPF::JSLE_ri:
307
38
    case BPF::JSLT_ri:
308
38
    case BPF::JUGE_ri:
309
38
    case BPF::JUGT_ri:
310
38
    case BPF::JULE_ri:
311
38
    case BPF::JULT_ri: {
312
38
      // op: dst
313
38
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
314
38
      Value |= (op & UINT64_C(15)) << 48;
315
38
      // op: BrDst
316
38
      op = getMachineOpValue(MI, MI.getOperand(2), Fixups, STI);
317
38
      Value |= (op & UINT64_C(65535)) << 32;
318
38
      // op: imm
319
38
      op = getMachineOpValue(MI, MI.getOperand(1), Fixups, STI);
320
38
      Value |= op & UINT64_C(4294967295);
321
38
      break;
322
38
    }
323
46
    case BPF::LDB:
324
46
    case BPF::LDB32:
325
46
    case BPF::LDD:
326
46
    case BPF::LDH:
327
46
    case BPF::LDH32:
328
46
    case BPF::LDW:
329
46
    case BPF::LDW32: {
330
46
      // op: dst
331
46
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
332
46
      Value |= (op & UINT64_C(15)) << 48;
333
46
      // op: addr
334
46
      op = getMemoryOpValue(MI, 1, Fixups, STI);
335
46
      Value |= (op & UINT64_C(983040)) << 36;
336
46
      Value |= (op & UINT64_C(65535)) << 32;
337
46
      break;
338
46
    }
339
105
    case BPF::LD_imm64:
340
105
    case BPF::MOV_ri:
341
105
    case BPF::MOV_ri_32: {
342
105
      // op: dst
343
105
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
344
105
      Value |= (op & UINT64_C(15)) << 48;
345
105
      // op: imm
346
105
      op = getMachineOpValue(MI, MI.getOperand(1), Fixups, STI);
347
105
      Value |= op & UINT64_C(4294967295);
348
105
      break;
349
105
    }
350
133
    case BPF::ADD_ri:
351
133
    case BPF::ADD_ri_32:
352
133
    case BPF::AND_ri:
353
133
    case BPF::AND_ri_32:
354
133
    case BPF::DIV_ri:
355
133
    case BPF::DIV_ri_32:
356
133
    case BPF::MUL_ri:
357
133
    case BPF::MUL_ri_32:
358
133
    case BPF::OR_ri:
359
133
    case BPF::OR_ri_32:
360
133
    case BPF::SLL_ri:
361
133
    case BPF::SLL_ri_32:
362
133
    case BPF::SRA_ri:
363
133
    case BPF::SRA_ri_32:
364
133
    case BPF::SRL_ri:
365
133
    case BPF::SRL_ri_32:
366
133
    case BPF::SUB_ri:
367
133
    case BPF::SUB_ri_32:
368
133
    case BPF::XOR_ri:
369
133
    case BPF::XOR_ri_32: {
370
133
      // op: dst
371
133
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
372
133
      Value |= (op & UINT64_C(15)) << 48;
373
133
      // op: imm
374
133
      op = getMachineOpValue(MI, MI.getOperand(2), Fixups, STI);
375
133
      Value |= op & UINT64_C(4294967295);
376
133
      break;
377
133
    }
378
133
    case BPF::LD_pseudo: {
379
4
      // op: dst
380
4
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
381
4
      Value |= (op & UINT64_C(15)) << 48;
382
4
      // op: imm
383
4
      op = getMachineOpValue(MI, MI.getOperand(2), Fixups, STI);
384
4
      Value |= op & UINT64_C(4294967295);
385
4
      // op: pseudo
386
4
      op = getMachineOpValue(MI, MI.getOperand(1), Fixups, STI);
387
4
      Value |= (op & UINT64_C(15)) << 52;
388
4
      break;
389
133
    }
390
173
    case BPF::MOV_32_64:
391
173
    case BPF::MOV_rr:
392
173
    case BPF::MOV_rr_32: {
393
173
      // op: dst
394
173
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
395
173
      Value |= (op & UINT64_C(15)) << 48;
396
173
      // op: src
397
173
      op = getMachineOpValue(MI, MI.getOperand(1), Fixups, STI);
398
173
      Value |= (op & UINT64_C(15)) << 52;
399
173
      break;
400
173
    }
401
173
    case BPF::JEQ_rr:
402
18
    case BPF::JNE_rr:
403
18
    case BPF::JSGE_rr:
404
18
    case BPF::JSGT_rr:
405
18
    case BPF::JSLE_rr:
406
18
    case BPF::JSLT_rr:
407
18
    case BPF::JUGE_rr:
408
18
    case BPF::JUGT_rr:
409
18
    case BPF::JULE_rr:
410
18
    case BPF::JULT_rr: {
411
18
      // op: dst
412
18
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
413
18
      Value |= (op & UINT64_C(15)) << 48;
414
18
      // op: src
415
18
      op = getMachineOpValue(MI, MI.getOperand(1), Fixups, STI);
416
18
      Value |= (op & UINT64_C(15)) << 52;
417
18
      // op: BrDst
418
18
      op = getMachineOpValue(MI, MI.getOperand(2), Fixups, STI);
419
18
      Value |= (op & UINT64_C(65535)) << 32;
420
18
      break;
421
18
    }
422
92
    case BPF::ADD_rr:
423
92
    case BPF::ADD_rr_32:
424
92
    case BPF::AND_rr:
425
92
    case BPF::AND_rr_32:
426
92
    case BPF::DIV_rr:
427
92
    case BPF::DIV_rr_32:
428
92
    case BPF::MUL_rr:
429
92
    case BPF::MUL_rr_32:
430
92
    case BPF::OR_rr:
431
92
    case BPF::OR_rr_32:
432
92
    case BPF::SLL_rr:
433
92
    case BPF::SLL_rr_32:
434
92
    case BPF::SRA_rr:
435
92
    case BPF::SRA_rr_32:
436
92
    case BPF::SRL_rr:
437
92
    case BPF::SRL_rr_32:
438
92
    case BPF::SUB_rr:
439
92
    case BPF::SUB_rr_32:
440
92
    case BPF::XOR_rr:
441
92
    case BPF::XOR_rr_32: {
442
92
      // op: dst
443
92
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
444
92
      Value |= (op & UINT64_C(15)) << 48;
445
92
      // op: src
446
92
      op = getMachineOpValue(MI, MI.getOperand(2), Fixups, STI);
447
92
      Value |= (op & UINT64_C(15)) << 52;
448
92
      break;
449
92
    }
450
92
    case BPF::XADD32:
451
7
    case BPF::XADD64: {
452
7
      // op: dst
453
7
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
454
7
      Value |= (op & UINT64_C(15)) << 52;
455
7
      // op: addr
456
7
      op = getMemoryOpValue(MI, 1, Fixups, STI);
457
7
      Value |= (op & UINT64_C(1048575)) << 32;
458
7
      break;
459
7
    }
460
17
    case BPF::LD_ABS_B:
461
17
    case BPF::LD_ABS_H:
462
17
    case BPF::LD_ABS_W: {
463
17
      // op: imm
464
17
      op = getMachineOpValue(MI, MI.getOperand(1), Fixups, STI);
465
17
      Value |= op & UINT64_C(4294967295);
466
17
      break;
467
17
    }
468
65
    case BPF::STB:
469
65
    case BPF::STB32:
470
65
    case BPF::STD:
471
65
    case BPF::STH:
472
65
    case BPF::STH32:
473
65
    case BPF::STW:
474
65
    case BPF::STW32: {
475
65
      // op: src
476
65
      op = getMachineOpValue(MI, MI.getOperand(0), Fixups, STI);
477
65
      Value |= (op & UINT64_C(15)) << 52;
478
65
      // op: addr
479
65
      op = getMemoryOpValue(MI, 1, Fixups, STI);
480
65
      Value |= (op & UINT64_C(1048575)) << 32;
481
65
      break;
482
65
    }
483
65
    case BPF::LD_IND_B:
484
47
    case BPF::LD_IND_H:
485
47
    case BPF::LD_IND_W: {
486
47
      // op: val
487
47
      op = getMachineOpValue(MI, MI.getOperand(1), Fixups, STI);
488
47
      Value |= (op & UINT64_C(15)) << 52;
489
47
      break;
490
47
    }
491
47
  default:
492
0
    std::string msg;
493
0
    raw_string_ostream Msg(msg);
494
0
    Msg << "Not supported instr: " << MI;
495
0
    report_fatal_error(Msg.str());
496
868
  }
497
868
  return Value;
498
868
}
499
500
#ifdef ENABLE_INSTR_PREDICATE_VERIFIER
501
#undef ENABLE_INSTR_PREDICATE_VERIFIER
502
#include <sstream>
503
504
// Flags for subtarget features that participate in instruction matching.
505
enum SubtargetFeatureFlag : uint8_t {
506
  Feature_None = 0
507
};
508
509
#ifndef NDEBUG
510
static const char *SubtargetFeatureNames[] = {
511
  nullptr
512
};
513
514
#endif // NDEBUG
515
uint64_t BPFMCCodeEmitter::
516
868
computeAvailableFeatures(const FeatureBitset& FB) const {
517
868
  uint64_t Features = 0;
518
868
  return Features;
519
868
}
520
521
void BPFMCCodeEmitter::verifyInstructionPredicates(
522
868
    const MCInst &Inst, uint64_t AvailableFeatures) const {
523
#ifndef NDEBUG
524
  static uint64_t RequiredFeatures[] = {
525
    0, // PHI = 0
526
    0, // INLINEASM = 1
527
    0, // CFI_INSTRUCTION = 2
528
    0, // EH_LABEL = 3
529
    0, // GC_LABEL = 4
530
    0, // ANNOTATION_LABEL = 5
531
    0, // KILL = 6
532
    0, // EXTRACT_SUBREG = 7
533
    0, // INSERT_SUBREG = 8
534
    0, // IMPLICIT_DEF = 9
535
    0, // SUBREG_TO_REG = 10
536
    0, // COPY_TO_REGCLASS = 11
537
    0, // DBG_VALUE = 12
538
    0, // DBG_LABEL = 13
539
    0, // REG_SEQUENCE = 14
540
    0, // COPY = 15
541
    0, // BUNDLE = 16
542
    0, // LIFETIME_START = 17
543
    0, // LIFETIME_END = 18
544
    0, // STACKMAP = 19
545
    0, // FENTRY_CALL = 20
546
    0, // PATCHPOINT = 21
547
    0, // LOAD_STACK_GUARD = 22
548
    0, // STATEPOINT = 23
549
    0, // LOCAL_ESCAPE = 24
550
    0, // FAULTING_OP = 25
551
    0, // PATCHABLE_OP = 26
552
    0, // PATCHABLE_FUNCTION_ENTER = 27
553
    0, // PATCHABLE_RET = 28
554
    0, // PATCHABLE_FUNCTION_EXIT = 29
555
    0, // PATCHABLE_TAIL_CALL = 30
556
    0, // PATCHABLE_EVENT_CALL = 31
557
    0, // PATCHABLE_TYPED_EVENT_CALL = 32
558
    0, // ICALL_BRANCH_FUNNEL = 33
559
    0, // G_ADD = 34
560
    0, // G_SUB = 35
561
    0, // G_MUL = 36
562
    0, // G_SDIV = 37
563
    0, // G_UDIV = 38
564
    0, // G_SREM = 39
565
    0, // G_UREM = 40
566
    0, // G_AND = 41
567
    0, // G_OR = 42
568
    0, // G_XOR = 43
569
    0, // G_IMPLICIT_DEF = 44
570
    0, // G_PHI = 45
571
    0, // G_FRAME_INDEX = 46
572
    0, // G_GLOBAL_VALUE = 47
573
    0, // G_EXTRACT = 48
574
    0, // G_UNMERGE_VALUES = 49
575
    0, // G_INSERT = 50
576
    0, // G_MERGE_VALUES = 51
577
    0, // G_PTRTOINT = 52
578
    0, // G_INTTOPTR = 53
579
    0, // G_BITCAST = 54
580
    0, // G_INTRINSIC_TRUNC = 55
581
    0, // G_INTRINSIC_ROUND = 56
582
    0, // G_LOAD = 57
583
    0, // G_SEXTLOAD = 58
584
    0, // G_ZEXTLOAD = 59
585
    0, // G_STORE = 60
586
    0, // G_ATOMIC_CMPXCHG_WITH_SUCCESS = 61
587
    0, // G_ATOMIC_CMPXCHG = 62
588
    0, // G_ATOMICRMW_XCHG = 63
589
    0, // G_ATOMICRMW_ADD = 64
590
    0, // G_ATOMICRMW_SUB = 65
591
    0, // G_ATOMICRMW_AND = 66
592
    0, // G_ATOMICRMW_NAND = 67
593
    0, // G_ATOMICRMW_OR = 68
594
    0, // G_ATOMICRMW_XOR = 69
595
    0, // G_ATOMICRMW_MAX = 70
596
    0, // G_ATOMICRMW_MIN = 71
597
    0, // G_ATOMICRMW_UMAX = 72
598
    0, // G_ATOMICRMW_UMIN = 73
599
    0, // G_BRCOND = 74
600
    0, // G_BRINDIRECT = 75
601
    0, // G_INTRINSIC = 76
602
    0, // G_INTRINSIC_W_SIDE_EFFECTS = 77
603
    0, // G_ANYEXT = 78
604
    0, // G_TRUNC = 79
605
    0, // G_CONSTANT = 80
606
    0, // G_FCONSTANT = 81
607
    0, // G_VASTART = 82
608
    0, // G_VAARG = 83
609
    0, // G_SEXT = 84
610
    0, // G_ZEXT = 85
611
    0, // G_SHL = 86
612
    0, // G_LSHR = 87
613
    0, // G_ASHR = 88
614
    0, // G_ICMP = 89
615
    0, // G_FCMP = 90
616
    0, // G_SELECT = 91
617
    0, // G_UADDO = 92
618
    0, // G_UADDE = 93
619
    0, // G_USUBO = 94
620
    0, // G_USUBE = 95
621
    0, // G_SADDO = 96
622
    0, // G_SADDE = 97
623
    0, // G_SSUBO = 98
624
    0, // G_SSUBE = 99
625
    0, // G_UMULO = 100
626
    0, // G_SMULO = 101
627
    0, // G_UMULH = 102
628
    0, // G_SMULH = 103
629
    0, // G_FADD = 104
630
    0, // G_FSUB = 105
631
    0, // G_FMUL = 106
632
    0, // G_FMA = 107
633
    0, // G_FDIV = 108
634
    0, // G_FREM = 109
635
    0, // G_FPOW = 110
636
    0, // G_FEXP = 111
637
    0, // G_FEXP2 = 112
638
    0, // G_FLOG = 113
639
    0, // G_FLOG2 = 114
640
    0, // G_FNEG = 115
641
    0, // G_FPEXT = 116
642
    0, // G_FPTRUNC = 117
643
    0, // G_FPTOSI = 118
644
    0, // G_FPTOUI = 119
645
    0, // G_SITOFP = 120
646
    0, // G_UITOFP = 121
647
    0, // G_FABS = 122
648
    0, // G_GEP = 123
649
    0, // G_PTR_MASK = 124
650
    0, // G_BR = 125
651
    0, // G_INSERT_VECTOR_ELT = 126
652
    0, // G_EXTRACT_VECTOR_ELT = 127
653
    0, // G_SHUFFLE_VECTOR = 128
654
    0, // G_CTTZ = 129
655
    0, // G_CTTZ_ZERO_UNDEF = 130
656
    0, // G_CTLZ = 131
657
    0, // G_CTLZ_ZERO_UNDEF = 132
658
    0, // G_CTPOP = 133
659
    0, // G_BSWAP = 134
660
    0, // G_ADDRSPACE_CAST = 135
661
    0, // G_BLOCK_ADDR = 136
662
    0, // ADJCALLSTACKDOWN = 137
663
    0, // ADJCALLSTACKUP = 138
664
    0, // MEMCPY = 139
665
    0, // Select = 140
666
    0, // Select_32 = 141
667
    0, // Select_32_64 = 142
668
    0, // Select_64_32 = 143
669
    0, // Select_Ri = 144
670
    0, // Select_Ri_32 = 145
671
    0, // Select_Ri_32_64 = 146
672
    0, // Select_Ri_64_32 = 147
673
    0, // ADD_ri = 148
674
    0, // ADD_ri_32 = 149
675
    0, // ADD_rr = 150
676
    0, // ADD_rr_32 = 151
677
    0, // AND_ri = 152
678
    0, // AND_ri_32 = 153
679
    0, // AND_rr = 154
680
    0, // AND_rr_32 = 155
681
    0, // BE16 = 156
682
    0, // BE32 = 157
683
    0, // BE64 = 158
684
    0, // DIV_ri = 159
685
    0, // DIV_ri_32 = 160
686
    0, // DIV_rr = 161
687
    0, // DIV_rr_32 = 162
688
    0, // FI_ri = 163
689
    0, // JAL = 164
690
    0, // JALX = 165
691
    0, // JEQ_ri = 166
692
    0, // JEQ_rr = 167
693
    0, // JMP = 168
694
    0, // JNE_ri = 169
695
    0, // JNE_rr = 170
696
    0, // JSGE_ri = 171
697
    0, // JSGE_rr = 172
698
    0, // JSGT_ri = 173
699
    0, // JSGT_rr = 174
700
    0, // JSLE_ri = 175
701
    0, // JSLE_rr = 176
702
    0, // JSLT_ri = 177
703
    0, // JSLT_rr = 178
704
    0, // JUGE_ri = 179
705
    0, // JUGE_rr = 180
706
    0, // JUGT_ri = 181
707
    0, // JUGT_rr = 182
708
    0, // JULE_ri = 183
709
    0, // JULE_rr = 184
710
    0, // JULT_ri = 185
711
    0, // JULT_rr = 186
712
    0, // LDB = 187
713
    0, // LDB32 = 188
714
    0, // LDD = 189
715
    0, // LDH = 190
716
    0, // LDH32 = 191
717
    0, // LDW = 192
718
    0, // LDW32 = 193
719
    0, // LD_ABS_B = 194
720
    0, // LD_ABS_H = 195
721
    0, // LD_ABS_W = 196
722
    0, // LD_IND_B = 197
723
    0, // LD_IND_H = 198
724
    0, // LD_IND_W = 199
725
    0, // LD_imm64 = 200
726
    0, // LD_pseudo = 201
727
    0, // LE16 = 202
728
    0, // LE32 = 203
729
    0, // LE64 = 204
730
    0, // MOV_32_64 = 205
731
    0, // MOV_ri = 206
732
    0, // MOV_ri_32 = 207
733
    0, // MOV_rr = 208
734
    0, // MOV_rr_32 = 209
735
    0, // MUL_ri = 210
736
    0, // MUL_ri_32 = 211
737
    0, // MUL_rr = 212
738
    0, // MUL_rr_32 = 213
739
    0, // NEG_32 = 214
740
    0, // NEG_64 = 215
741
    0, // NOP = 216
742
    0, // OR_ri = 217
743
    0, // OR_ri_32 = 218
744
    0, // OR_rr = 219
745
    0, // OR_rr_32 = 220
746
    0, // RET = 221
747
    0, // SLL_ri = 222
748
    0, // SLL_ri_32 = 223
749
    0, // SLL_rr = 224
750
    0, // SLL_rr_32 = 225
751
    0, // SRA_ri = 226
752
    0, // SRA_ri_32 = 227
753
    0, // SRA_rr = 228
754
    0, // SRA_rr_32 = 229
755
    0, // SRL_ri = 230
756
    0, // SRL_ri_32 = 231
757
    0, // SRL_rr = 232
758
    0, // SRL_rr_32 = 233
759
    0, // STB = 234
760
    0, // STB32 = 235
761
    0, // STD = 236
762
    0, // STH = 237
763
    0, // STH32 = 238
764
    0, // STW = 239
765
    0, // STW32 = 240
766
    0, // SUB_ri = 241
767
    0, // SUB_ri_32 = 242
768
    0, // SUB_rr = 243
769
    0, // SUB_rr_32 = 244
770
    0, // XADD32 = 245
771
    0, // XADD64 = 246
772
    0, // XOR_ri = 247
773
    0, // XOR_ri_32 = 248
774
    0, // XOR_rr = 249
775
    0, // XOR_rr_32 = 250
776
  };
777
778
  assert(Inst.getOpcode() < 251);
779
  uint64_t MissingFeatures =
780
      (AvailableFeatures & RequiredFeatures[Inst.getOpcode()]) ^
781
      RequiredFeatures[Inst.getOpcode()];
782
  if (MissingFeatures) {
783
    std::ostringstream Msg;
784
    Msg << "Attempting to emit " << MCII.getName(Inst.getOpcode()).str()
785
        << " instruction but the ";
786
    for (unsigned i = 0; i < 8 * sizeof(MissingFeatures); ++i)
787
      if (MissingFeatures & (1ULL << i))
788
        Msg << SubtargetFeatureNames[i] << " ";
789
    Msg << "predicate(s) are not met";
790
    report_fatal_error(Msg.str());
791
  }
792
#else
793
// Silence unused variable warning on targets that don't use MCII for other purposes (e.g. BPF).
794
868
(void)MCII;
795
868
#endif // NDEBUG
796
868
}
797
#endif