Coverage Report

Created: 2019-02-15 18:59

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