1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
2 | |* *| |
3 | |* Machine Code Emitter *| |
4 | |* *| |
5 | |* Automatically generated file, do not edit! *| |
6 | |* *| |
7 | \*===----------------------------------------------------------------------===*/ |
8 | |
9 | uint64_t LanaiMCCodeEmitter::getBinaryCodeForInstr(const MCInst &MI, |
10 | SmallVectorImpl<MCFixup> &Fixups, |
11 | const MCSubtargetInfo &STI) const { |
12 | static const uint64_t InstBits[] = { |
13 | UINT64_C(0), |
14 | UINT64_C(0), |
15 | UINT64_C(0), |
16 | UINT64_C(0), |
17 | UINT64_C(0), |
18 | UINT64_C(0), |
19 | UINT64_C(0), |
20 | UINT64_C(0), |
21 | UINT64_C(0), |
22 | UINT64_C(0), |
23 | UINT64_C(0), |
24 | UINT64_C(0), |
25 | UINT64_C(0), |
26 | UINT64_C(0), |
27 | UINT64_C(0), |
28 | UINT64_C(0), |
29 | UINT64_C(0), |
30 | UINT64_C(0), |
31 | UINT64_C(0), |
32 | UINT64_C(0), |
33 | UINT64_C(0), |
34 | UINT64_C(0), |
35 | UINT64_C(0), |
36 | UINT64_C(0), |
37 | UINT64_C(0), |
38 | UINT64_C(0), |
39 | UINT64_C(0), |
40 | UINT64_C(0), |
41 | UINT64_C(0), |
42 | UINT64_C(0), |
43 | UINT64_C(0), |
44 | UINT64_C(0), |
45 | UINT64_C(0), |
46 | UINT64_C(0), |
47 | UINT64_C(0), |
48 | UINT64_C(0), |
49 | UINT64_C(0), |
50 | UINT64_C(0), |
51 | UINT64_C(0), |
52 | UINT64_C(0), |
53 | UINT64_C(0), |
54 | UINT64_C(0), |
55 | UINT64_C(0), |
56 | UINT64_C(0), |
57 | UINT64_C(0), |
58 | UINT64_C(0), |
59 | UINT64_C(0), |
60 | UINT64_C(0), |
61 | UINT64_C(0), |
62 | UINT64_C(0), |
63 | UINT64_C(0), |
64 | UINT64_C(0), |
65 | UINT64_C(0), |
66 | UINT64_C(0), |
67 | UINT64_C(0), |
68 | UINT64_C(0), |
69 | UINT64_C(0), |
70 | UINT64_C(0), |
71 | UINT64_C(0), |
72 | UINT64_C(0), |
73 | UINT64_C(0), |
74 | UINT64_C(0), |
75 | UINT64_C(0), |
76 | UINT64_C(0), |
77 | UINT64_C(0), |
78 | UINT64_C(0), |
79 | UINT64_C(0), |
80 | UINT64_C(0), |
81 | UINT64_C(0), |
82 | UINT64_C(0), |
83 | UINT64_C(0), |
84 | UINT64_C(0), |
85 | UINT64_C(0), |
86 | UINT64_C(0), |
87 | UINT64_C(0), |
88 | UINT64_C(0), |
89 | UINT64_C(0), |
90 | UINT64_C(0), |
91 | UINT64_C(0), |
92 | UINT64_C(0), |
93 | UINT64_C(0), |
94 | UINT64_C(0), |
95 | UINT64_C(0), |
96 | UINT64_C(0), |
97 | UINT64_C(0), |
98 | UINT64_C(0), |
99 | UINT64_C(0), |
100 | UINT64_C(0), |
101 | UINT64_C(0), |
102 | UINT64_C(0), |
103 | UINT64_C(0), |
104 | UINT64_C(0), |
105 | UINT64_C(0), |
106 | UINT64_C(0), |
107 | UINT64_C(0), |
108 | UINT64_C(0), |
109 | UINT64_C(0), |
110 | UINT64_C(0), |
111 | UINT64_C(0), |
112 | UINT64_C(0), |
113 | UINT64_C(0), |
114 | UINT64_C(0), |
115 | UINT64_C(0), |
116 | UINT64_C(0), |
117 | UINT64_C(0), |
118 | UINT64_C(0), |
119 | UINT64_C(0), |
120 | UINT64_C(0), |
121 | UINT64_C(0), |
122 | UINT64_C(0), |
123 | UINT64_C(0), |
124 | UINT64_C(0), |
125 | UINT64_C(0), |
126 | UINT64_C(0), |
127 | UINT64_C(0), |
128 | UINT64_C(0), |
129 | UINT64_C(0), |
130 | UINT64_C(0), |
131 | UINT64_C(0), |
132 | UINT64_C(0), |
133 | UINT64_C(0), |
134 | UINT64_C(0), |
135 | UINT64_C(0), |
136 | UINT64_C(0), |
137 | UINT64_C(0), |
138 | UINT64_C(0), |
139 | UINT64_C(0), |
140 | UINT64_C(0), |
141 | UINT64_C(0), |
142 | UINT64_C(0), |
143 | UINT64_C(0), |
144 | UINT64_C(0), |
145 | UINT64_C(0), |
146 | UINT64_C(0), |
147 | UINT64_C(0), |
148 | UINT64_C(0), |
149 | UINT64_C(0), |
150 | UINT64_C(0), |
151 | UINT64_C(0), |
152 | UINT64_C(0), |
153 | UINT64_C(0), |
154 | UINT64_C(0), |
155 | UINT64_C(0), |
156 | UINT64_C(0), |
157 | UINT64_C(0), |
158 | UINT64_C(0), |
159 | UINT64_C(0), |
160 | UINT64_C(0), |
161 | UINT64_C(0), |
162 | UINT64_C(0), |
163 | UINT64_C(0), |
164 | UINT64_C(0), |
165 | UINT64_C(0), |
166 | UINT64_C(0), |
167 | UINT64_C(0), |
168 | UINT64_C(0), |
169 | UINT64_C(0), |
170 | UINT64_C(0), |
171 | UINT64_C(0), |
172 | UINT64_C(0), |
173 | UINT64_C(0), |
174 | UINT64_C(0), |
175 | UINT64_C(0), |
176 | UINT64_C(0), |
177 | UINT64_C(0), |
178 | UINT64_C(0), |
179 | UINT64_C(0), |
180 | UINT64_C(0), |
181 | UINT64_C(0), |
182 | UINT64_C(0), |
183 | UINT64_C(0), |
184 | UINT64_C(0), |
185 | UINT64_C(0), |
186 | UINT64_C(0), |
187 | UINT64_C(0), |
188 | UINT64_C(0), |
189 | UINT64_C(0), |
190 | UINT64_C(0), |
191 | UINT64_C(0), |
192 | UINT64_C(0), |
193 | UINT64_C(0), |
194 | UINT64_C(0), |
195 | UINT64_C(0), |
196 | UINT64_C(0), |
197 | UINT64_C(0), |
198 | UINT64_C(0), |
199 | UINT64_C(0), |
200 | UINT64_C(0), |
201 | UINT64_C(0), |
202 | UINT64_C(0), |
203 | UINT64_C(0), |
204 | UINT64_C(0), |
205 | UINT64_C(0), |
206 | UINT64_C(0), |
207 | UINT64_C(0), |
208 | UINT64_C(0), |
209 | UINT64_C(0), |
210 | UINT64_C(0), |
211 | UINT64_C(0), |
212 | UINT64_C(0), |
213 | UINT64_C(0), |
214 | UINT64_C(0), |
215 | UINT64_C(0), |
216 | UINT64_C(0), |
217 | UINT64_C(0), |
218 | UINT64_C(0), |
219 | UINT64_C(0), |
220 | UINT64_C(0), |
221 | UINT64_C(0), |
222 | UINT64_C(0), |
223 | UINT64_C(0), |
224 | UINT64_C(0), |
225 | UINT64_C(0), |
226 | UINT64_C(0), |
227 | UINT64_C(0), |
228 | UINT64_C(0), |
229 | UINT64_C(0), |
230 | UINT64_C(0), |
231 | UINT64_C(0), |
232 | UINT64_C(0), |
233 | UINT64_C(0), |
234 | UINT64_C(0), |
235 | UINT64_C(0), |
236 | UINT64_C(0), |
237 | UINT64_C(0), |
238 | UINT64_C(0), |
239 | UINT64_C(0), |
240 | UINT64_C(0), |
241 | UINT64_C(0), |
242 | UINT64_C(0), |
243 | UINT64_C(0), |
244 | UINT64_C(0), |
245 | UINT64_C(0), |
246 | UINT64_C(0), |
247 | UINT64_C(0), |
248 | UINT64_C(0), |
249 | UINT64_C(0), |
250 | UINT64_C(0), |
251 | UINT64_C(0), |
252 | UINT64_C(0), |
253 | UINT64_C(0), |
254 | UINT64_C(0), |
255 | UINT64_C(0), |
256 | UINT64_C(0), |
257 | UINT64_C(0), |
258 | UINT64_C(0), |
259 | UINT64_C(0), |
260 | UINT64_C(0), |
261 | UINT64_C(0), |
262 | UINT64_C(0), |
263 | UINT64_C(0), |
264 | UINT64_C(0), |
265 | UINT64_C(0), |
266 | UINT64_C(0), |
267 | UINT64_C(0), |
268 | UINT64_C(0), |
269 | UINT64_C(0), |
270 | UINT64_C(0), |
271 | UINT64_C(0), |
272 | UINT64_C(0), |
273 | UINT64_C(0), |
274 | UINT64_C(0), |
275 | UINT64_C(0), |
276 | UINT64_C(0), |
277 | UINT64_C(0), |
278 | UINT64_C(0), |
279 | UINT64_C(0), |
280 | UINT64_C(0), |
281 | UINT64_C(0), |
282 | UINT64_C(0), |
283 | UINT64_C(0), |
284 | UINT64_C(0), |
285 | UINT64_C(0), |
286 | UINT64_C(0), |
287 | UINT64_C(0), |
288 | UINT64_C(0), |
289 | UINT64_C(0), |
290 | UINT64_C(0), |
291 | UINT64_C(0), |
292 | UINT64_C(0), |
293 | UINT64_C(0), |
294 | UINT64_C(0), |
295 | UINT64_C(0), |
296 | UINT64_C(0), |
297 | UINT64_C(0), |
298 | UINT64_C(0), |
299 | UINT64_C(0), |
300 | UINT64_C(0), |
301 | UINT64_C(0), |
302 | UINT64_C(0), |
303 | UINT64_C(0), |
304 | UINT64_C(0), |
305 | UINT64_C(0), |
306 | UINT64_C(0), |
307 | UINT64_C(0), |
308 | UINT64_C(0), |
309 | UINT64_C(0), |
310 | UINT64_C(0), |
311 | UINT64_C(0), |
312 | UINT64_C(0), |
313 | UINT64_C(268632064), // ADDC_F_I_HI |
314 | UINT64_C(268566528), // ADDC_F_I_LO |
315 | UINT64_C(3221356800), // ADDC_F_R |
316 | UINT64_C(268500992), // ADDC_I_HI |
317 | UINT64_C(268435456), // ADDC_I_LO |
318 | UINT64_C(3221225728), // ADDC_R |
319 | UINT64_C(196608), // ADD_F_I_HI |
320 | UINT64_C(131072), // ADD_F_I_LO |
321 | UINT64_C(3221356544), // ADD_F_R |
322 | UINT64_C(65536), // ADD_I_HI |
323 | UINT64_C(0), // ADD_I_LO |
324 | UINT64_C(3221225472), // ADD_R |
325 | UINT64_C(1073938432), // AND_F_I_HI |
326 | UINT64_C(1073872896), // AND_F_I_LO |
327 | UINT64_C(3221357568), // AND_F_R |
328 | UINT64_C(1073807360), // AND_I_HI |
329 | UINT64_C(1073741824), // AND_I_LO |
330 | UINT64_C(3221226496), // AND_R |
331 | UINT64_C(3758096384), // BRCC |
332 | UINT64_C(3238003968), // BRIND_CC |
333 | UINT64_C(3238003968), // BRIND_CCA |
334 | UINT64_C(3774873602), // BRR |
335 | UINT64_C(3758096384), // BT |
336 | UINT64_C(3238003968), // JR |
337 | UINT64_C(4026531840), // LDADDR |
338 | UINT64_C(4026744832), // LDBs_RI |
339 | UINT64_C(2684354564), // LDBs_RR |
340 | UINT64_C(4026748928), // LDBz_RI |
341 | UINT64_C(2684354565), // LDBz_RR |
342 | UINT64_C(4026728448), // LDHs_RI |
343 | UINT64_C(2684354560), // LDHs_RR |
344 | UINT64_C(4026732544), // LDHz_RI |
345 | UINT64_C(2684354561), // LDHz_RR |
346 | UINT64_C(2147483648), // LDW_RI |
347 | UINT64_C(2684354562), // LDW_RR |
348 | UINT64_C(2684354563), // LDWz_RR |
349 | UINT64_C(3489660930), // LEADZ |
350 | UINT64_C(2), // LOG0 |
351 | UINT64_C(3), // LOG1 |
352 | UINT64_C(4), // LOG2 |
353 | UINT64_C(5), // LOG3 |
354 | UINT64_C(6), // LOG4 |
355 | UINT64_C(65536), // MOVHI |
356 | UINT64_C(1), // NOP |
357 | UINT64_C(1342373888), // OR_F_I_HI |
358 | UINT64_C(1342308352), // OR_F_I_LO |
359 | UINT64_C(3221357824), // OR_F_R |
360 | UINT64_C(1342242816), // OR_I_HI |
361 | UINT64_C(1342177280), // OR_I_LO |
362 | UINT64_C(3221226752), // OR_R |
363 | UINT64_C(3489660929), // POPC |
364 | UINT64_C(2165768188), // RET |
365 | UINT64_C(1879244800), // SA_F_I |
366 | UINT64_C(1879113728), // SA_I |
367 | UINT64_C(3758096386), // SCC |
368 | UINT64_C(3221227264), // SELECT |
369 | UINT64_C(537067520), // SFSUB_F_RI_HI |
370 | UINT64_C(537001984), // SFSUB_F_RI_LO |
371 | UINT64_C(3221357056), // SFSUB_F_RR |
372 | UINT64_C(3221358464), // SHL_F_R |
373 | UINT64_C(3221227392), // SHL_R |
374 | UINT64_C(4026662912), // SLI |
375 | UINT64_C(1879179264), // SL_F_I |
376 | UINT64_C(1879048192), // SL_I |
377 | UINT64_C(3221358528), // SRA_F_R |
378 | UINT64_C(3221227456), // SRA_R |
379 | UINT64_C(3221358464), // SRL_F_R |
380 | UINT64_C(3221227392), // SRL_R |
381 | UINT64_C(4026597376), // STADDR |
382 | UINT64_C(4026753024), // STB_RI |
383 | UINT64_C(2952790020), // STB_RR |
384 | UINT64_C(4026736640), // STH_RI |
385 | UINT64_C(2952790016), // STH_RR |
386 | UINT64_C(805502976), // SUBB_F_I_HI |
387 | UINT64_C(805437440), // SUBB_F_I_LO |
388 | UINT64_C(3221357312), // SUBB_F_R |
389 | UINT64_C(805371904), // SUBB_I_HI |
390 | UINT64_C(805306368), // SUBB_I_LO |
391 | UINT64_C(3221226240), // SUBB_R |
392 | UINT64_C(537067520), // SUB_F_I_HI |
393 | UINT64_C(537001984), // SUB_F_I_LO |
394 | UINT64_C(3221357056), // SUB_F_R |
395 | UINT64_C(536936448), // SUB_I_HI |
396 | UINT64_C(536870912), // SUB_I_LO |
397 | UINT64_C(3221225984), // SUB_R |
398 | UINT64_C(2415919104), // SW_RI |
399 | UINT64_C(2952790018), // SW_RR |
400 | UINT64_C(3489660931), // TRAILZ |
401 | UINT64_C(1610809344), // XOR_F_I_HI |
402 | UINT64_C(1610743808), // XOR_F_I_LO |
403 | UINT64_C(3221358080), // XOR_F_R |
404 | UINT64_C(1610678272), // XOR_I_HI |
405 | UINT64_C(1610612736), // XOR_I_LO |
406 | UINT64_C(3221227008), // XOR_R |
407 | UINT64_C(0) |
408 | }; |
409 | const unsigned opcode = MI.getOpcode(); |
410 | uint64_t Value = InstBits[opcode]; |
411 | uint64_t op = 0; |
412 | (void)op; // suppress warning |
413 | switch (opcode) { |
414 | case Lanai::LOG0: |
415 | case Lanai::LOG1: |
416 | case Lanai::LOG2: |
417 | case Lanai::LOG3: |
418 | case Lanai::LOG4: |
419 | case Lanai::NOP: |
420 | case Lanai::RET: { |
421 | break; |
422 | } |
423 | case Lanai::BRR: { |
424 | // op: DDDI |
425 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
426 | Value |= (op & UINT64_C(14)) << 24; |
427 | Value |= (op & UINT64_C(1)); |
428 | // op: imm16 |
429 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
430 | op &= UINT64_C(65532); |
431 | Value |= op; |
432 | break; |
433 | } |
434 | case Lanai::LEADZ: |
435 | case Lanai::POPC: |
436 | case Lanai::TRAILZ: { |
437 | // op: Rd |
438 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
439 | op &= UINT64_C(31); |
440 | op <<= 23; |
441 | Value |= op; |
442 | // op: Rs1 |
443 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
444 | op &= UINT64_C(31); |
445 | op <<= 18; |
446 | Value |= op; |
447 | break; |
448 | } |
449 | case Lanai::ADDC_F_R: |
450 | case Lanai::ADDC_R: |
451 | case Lanai::ADD_F_R: |
452 | case Lanai::ADD_R: |
453 | case Lanai::AND_F_R: |
454 | case Lanai::AND_R: |
455 | case Lanai::OR_F_R: |
456 | case Lanai::OR_R: |
457 | case Lanai::SELECT: |
458 | case Lanai::SHL_F_R: |
459 | case Lanai::SHL_R: |
460 | case Lanai::SRA_F_R: |
461 | case Lanai::SRA_R: |
462 | case Lanai::SRL_F_R: |
463 | case Lanai::SRL_R: |
464 | case Lanai::SUBB_F_R: |
465 | case Lanai::SUBB_R: |
466 | case Lanai::SUB_F_R: |
467 | case Lanai::SUB_R: |
468 | case Lanai::XOR_F_R: |
469 | case Lanai::XOR_R: { |
470 | // op: Rd |
471 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
472 | op &= UINT64_C(31); |
473 | op <<= 23; |
474 | Value |= op; |
475 | // op: Rs1 |
476 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
477 | op &= UINT64_C(31); |
478 | op <<= 18; |
479 | Value |= op; |
480 | // op: Rs2 |
481 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 2), Fixups, SubtargetInfo: STI); |
482 | op &= UINT64_C(31); |
483 | op <<= 11; |
484 | Value |= op; |
485 | // op: DDDI |
486 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 3), Fixups, SubtargetInfo: STI); |
487 | Value |= (op & UINT64_C(1)) << 16; |
488 | Value |= (op & UINT64_C(14)) >> 1; |
489 | break; |
490 | } |
491 | case Lanai::ADDC_F_I_HI: |
492 | case Lanai::ADDC_F_I_LO: |
493 | case Lanai::ADDC_I_HI: |
494 | case Lanai::ADDC_I_LO: |
495 | case Lanai::ADD_F_I_HI: |
496 | case Lanai::ADD_F_I_LO: |
497 | case Lanai::ADD_I_HI: |
498 | case Lanai::ADD_I_LO: |
499 | case Lanai::AND_F_I_HI: |
500 | case Lanai::AND_F_I_LO: |
501 | case Lanai::AND_I_HI: |
502 | case Lanai::AND_I_LO: |
503 | case Lanai::OR_F_I_HI: |
504 | case Lanai::OR_F_I_LO: |
505 | case Lanai::OR_I_HI: |
506 | case Lanai::OR_I_LO: |
507 | case Lanai::SA_F_I: |
508 | case Lanai::SA_I: |
509 | case Lanai::SL_F_I: |
510 | case Lanai::SL_I: |
511 | case Lanai::SUBB_F_I_HI: |
512 | case Lanai::SUBB_F_I_LO: |
513 | case Lanai::SUBB_I_HI: |
514 | case Lanai::SUBB_I_LO: |
515 | case Lanai::SUB_F_I_HI: |
516 | case Lanai::SUB_F_I_LO: |
517 | case Lanai::SUB_I_HI: |
518 | case Lanai::SUB_I_LO: |
519 | case Lanai::XOR_F_I_HI: |
520 | case Lanai::XOR_F_I_LO: |
521 | case Lanai::XOR_I_HI: |
522 | case Lanai::XOR_I_LO: { |
523 | // op: Rd |
524 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
525 | op &= UINT64_C(31); |
526 | op <<= 23; |
527 | Value |= op; |
528 | // op: Rs1 |
529 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
530 | op &= UINT64_C(31); |
531 | op <<= 18; |
532 | Value |= op; |
533 | // op: imm16 |
534 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 2), Fixups, SubtargetInfo: STI); |
535 | op &= UINT64_C(65535); |
536 | Value |= op; |
537 | break; |
538 | } |
539 | case Lanai::STADDR: { |
540 | // op: Rd |
541 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
542 | op &= UINT64_C(31); |
543 | op <<= 23; |
544 | Value |= op; |
545 | // op: dst |
546 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
547 | Value |= (op & UINT64_C(2031616)) << 2; |
548 | Value |= (op & UINT64_C(65535)); |
549 | break; |
550 | } |
551 | case Lanai::SW_RI: { |
552 | // op: Rd |
553 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
554 | op &= UINT64_C(31); |
555 | op <<= 23; |
556 | Value |= op; |
557 | // op: dst |
558 | op = getRiMemoryOpValue(Inst: MI, OpNo: 1, Fixups, SubtargetInfo: STI); |
559 | op &= UINT64_C(8388607); |
560 | Value |= op; |
561 | Value = adjustPqBitsRmAndRrm(Inst: MI, Value, STI); |
562 | break; |
563 | } |
564 | case Lanai::STB_RR: |
565 | case Lanai::STH_RR: |
566 | case Lanai::SW_RR: { |
567 | // op: Rd |
568 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
569 | op &= UINT64_C(31); |
570 | op <<= 23; |
571 | Value |= op; |
572 | // op: dst |
573 | op = getRrMemoryOpValue(Inst: MI, OpNo: 1, Fixups, SubtargetInfo: STI); |
574 | Value |= (op & UINT64_C(1015808)) << 3; |
575 | Value |= (op & UINT64_C(768)) << 8; |
576 | Value |= (op & UINT64_C(31744)) << 1; |
577 | Value |= (op & UINT64_C(255)) << 3; |
578 | Value = adjustPqBitsRmAndRrm(Inst: MI, Value, STI); |
579 | break; |
580 | } |
581 | case Lanai::STB_RI: |
582 | case Lanai::STH_RI: { |
583 | // op: Rd |
584 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
585 | op &= UINT64_C(31); |
586 | op <<= 23; |
587 | Value |= op; |
588 | // op: dst |
589 | op = getSplsOpValue(Inst: MI, OpNo: 1, Fixups, SubtargetInfo: STI); |
590 | Value |= (op & UINT64_C(126976)) << 6; |
591 | Value |= (op & UINT64_C(4095)); |
592 | Value = adjustPqBitsSpls(Inst: MI, Value, STI); |
593 | break; |
594 | } |
595 | case Lanai::SLI: { |
596 | // op: Rd |
597 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
598 | op &= UINT64_C(31); |
599 | op <<= 23; |
600 | Value |= op; |
601 | // op: imm |
602 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
603 | Value |= (op & UINT64_C(2031616)) << 2; |
604 | Value |= (op & UINT64_C(65535)); |
605 | break; |
606 | } |
607 | case Lanai::MOVHI: { |
608 | // op: Rd |
609 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
610 | op &= UINT64_C(31); |
611 | op <<= 23; |
612 | Value |= op; |
613 | // op: imm16 |
614 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
615 | op &= UINT64_C(65535); |
616 | Value |= op; |
617 | break; |
618 | } |
619 | case Lanai::LDADDR: { |
620 | // op: Rd |
621 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
622 | op &= UINT64_C(31); |
623 | op <<= 23; |
624 | Value |= op; |
625 | // op: src |
626 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
627 | Value |= (op & UINT64_C(2031616)) << 2; |
628 | Value |= (op & UINT64_C(65535)); |
629 | break; |
630 | } |
631 | case Lanai::LDW_RI: { |
632 | // op: Rd |
633 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
634 | op &= UINT64_C(31); |
635 | op <<= 23; |
636 | Value |= op; |
637 | // op: src |
638 | op = getRiMemoryOpValue(Inst: MI, OpNo: 1, Fixups, SubtargetInfo: STI); |
639 | op &= UINT64_C(8388607); |
640 | Value |= op; |
641 | Value = adjustPqBitsRmAndRrm(Inst: MI, Value, STI); |
642 | break; |
643 | } |
644 | case Lanai::LDBs_RR: |
645 | case Lanai::LDBz_RR: |
646 | case Lanai::LDHs_RR: |
647 | case Lanai::LDHz_RR: |
648 | case Lanai::LDW_RR: |
649 | case Lanai::LDWz_RR: { |
650 | // op: Rd |
651 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
652 | op &= UINT64_C(31); |
653 | op <<= 23; |
654 | Value |= op; |
655 | // op: src |
656 | op = getRrMemoryOpValue(Inst: MI, OpNo: 1, Fixups, SubtargetInfo: STI); |
657 | Value |= (op & UINT64_C(1015808)) << 3; |
658 | Value |= (op & UINT64_C(768)) << 8; |
659 | Value |= (op & UINT64_C(31744)) << 1; |
660 | Value |= (op & UINT64_C(255)) << 3; |
661 | Value = adjustPqBitsRmAndRrm(Inst: MI, Value, STI); |
662 | break; |
663 | } |
664 | case Lanai::LDBs_RI: |
665 | case Lanai::LDBz_RI: |
666 | case Lanai::LDHs_RI: |
667 | case Lanai::LDHz_RI: { |
668 | // op: Rd |
669 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
670 | op &= UINT64_C(31); |
671 | op <<= 23; |
672 | Value |= op; |
673 | // op: src |
674 | op = getSplsOpValue(Inst: MI, OpNo: 1, Fixups, SubtargetInfo: STI); |
675 | Value |= (op & UINT64_C(126976)) << 6; |
676 | Value |= (op & UINT64_C(4095)); |
677 | Value = adjustPqBitsSpls(Inst: MI, Value, STI); |
678 | break; |
679 | } |
680 | case Lanai::BRIND_CC: { |
681 | // op: Rs1 |
682 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
683 | op &= UINT64_C(31); |
684 | op <<= 18; |
685 | Value |= op; |
686 | // op: DDDI |
687 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
688 | Value |= (op & UINT64_C(1)) << 16; |
689 | Value |= (op & UINT64_C(14)) >> 1; |
690 | break; |
691 | } |
692 | case Lanai::SCC: { |
693 | // op: Rs1 |
694 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
695 | op &= UINT64_C(31); |
696 | op <<= 18; |
697 | Value |= op; |
698 | // op: DDDI |
699 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
700 | Value |= (op & UINT64_C(14)) << 24; |
701 | Value |= (op & UINT64_C(1)); |
702 | break; |
703 | } |
704 | case Lanai::SFSUB_F_RR: { |
705 | // op: Rs1 |
706 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
707 | op &= UINT64_C(31); |
708 | op <<= 18; |
709 | Value |= op; |
710 | // op: Rs2 |
711 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
712 | op &= UINT64_C(31); |
713 | op <<= 11; |
714 | Value |= op; |
715 | break; |
716 | } |
717 | case Lanai::BRIND_CCA: { |
718 | // op: Rs1 |
719 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
720 | op &= UINT64_C(31); |
721 | op <<= 18; |
722 | Value |= op; |
723 | // op: Rs2 |
724 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
725 | op &= UINT64_C(31); |
726 | op <<= 11; |
727 | Value |= op; |
728 | // op: DDDI |
729 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 2), Fixups, SubtargetInfo: STI); |
730 | Value |= (op & UINT64_C(1)) << 16; |
731 | Value |= (op & UINT64_C(14)) >> 1; |
732 | break; |
733 | } |
734 | case Lanai::SFSUB_F_RI_HI: |
735 | case Lanai::SFSUB_F_RI_LO: { |
736 | // op: Rs1 |
737 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
738 | op &= UINT64_C(31); |
739 | op <<= 18; |
740 | Value |= op; |
741 | // op: imm16 |
742 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
743 | op &= UINT64_C(65535); |
744 | Value |= op; |
745 | break; |
746 | } |
747 | case Lanai::JR: { |
748 | // op: Rs2 |
749 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 0), Fixups, SubtargetInfo: STI); |
750 | op &= UINT64_C(31); |
751 | op <<= 11; |
752 | Value |= op; |
753 | break; |
754 | } |
755 | case Lanai::BT: { |
756 | // op: addr |
757 | op = getBranchTargetOpValue(Inst: MI, OpNo: 0, Fixups, SubtargetInfo: STI); |
758 | op &= UINT64_C(33554428); |
759 | Value |= op; |
760 | break; |
761 | } |
762 | case Lanai::BRCC: { |
763 | // op: addr |
764 | op = getBranchTargetOpValue(Inst: MI, OpNo: 0, Fixups, SubtargetInfo: STI); |
765 | op &= UINT64_C(33554428); |
766 | Value |= op; |
767 | // op: DDDI |
768 | op = getMachineOpValue(Inst: MI, MCOp: MI.getOperand(i: 1), Fixups, SubtargetInfo: STI); |
769 | Value |= (op & UINT64_C(14)) << 24; |
770 | Value |= (op & UINT64_C(1)); |
771 | break; |
772 | } |
773 | default: |
774 | std::string msg; |
775 | raw_string_ostream Msg(msg); |
776 | Msg << "Not supported instr: " << MI; |
777 | report_fatal_error(reason: Msg.str().c_str()); |
778 | } |
779 | return Value; |
780 | } |
781 | |
782 | #ifdef GET_OPERAND_BIT_OFFSET |
783 | #undef GET_OPERAND_BIT_OFFSET |
784 | |
785 | uint32_t LanaiMCCodeEmitter::getOperandBitOffset(const MCInst &MI, |
786 | unsigned OpNum, |
787 | const MCSubtargetInfo &STI) const { |
788 | switch (MI.getOpcode()) { |
789 | case Lanai::LOG0: |
790 | case Lanai::LOG1: |
791 | case Lanai::LOG2: |
792 | case Lanai::LOG3: |
793 | case Lanai::LOG4: |
794 | case Lanai::NOP: |
795 | case Lanai::RET: { |
796 | break; |
797 | } |
798 | case Lanai::ADDC_F_R: |
799 | case Lanai::ADDC_R: |
800 | case Lanai::ADD_F_R: |
801 | case Lanai::ADD_R: |
802 | case Lanai::AND_F_R: |
803 | case Lanai::AND_R: |
804 | case Lanai::OR_F_R: |
805 | case Lanai::OR_R: |
806 | case Lanai::SELECT: |
807 | case Lanai::SHL_F_R: |
808 | case Lanai::SHL_R: |
809 | case Lanai::SRA_F_R: |
810 | case Lanai::SRA_R: |
811 | case Lanai::SRL_F_R: |
812 | case Lanai::SRL_R: |
813 | case Lanai::SUBB_F_R: |
814 | case Lanai::SUBB_R: |
815 | case Lanai::SUB_F_R: |
816 | case Lanai::SUB_R: |
817 | case Lanai::XOR_F_R: |
818 | case Lanai::XOR_R: { |
819 | switch (OpNum) { |
820 | case 0: |
821 | // op: Rd |
822 | return 23; |
823 | case 1: |
824 | // op: Rs1 |
825 | return 18; |
826 | case 2: |
827 | // op: Rs2 |
828 | return 11; |
829 | case 3: |
830 | // op: DDDI |
831 | return 0; |
832 | } |
833 | break; |
834 | } |
835 | case Lanai::ADDC_F_I_HI: |
836 | case Lanai::ADDC_F_I_LO: |
837 | case Lanai::ADDC_I_HI: |
838 | case Lanai::ADDC_I_LO: |
839 | case Lanai::ADD_F_I_HI: |
840 | case Lanai::ADD_F_I_LO: |
841 | case Lanai::ADD_I_HI: |
842 | case Lanai::ADD_I_LO: |
843 | case Lanai::AND_F_I_HI: |
844 | case Lanai::AND_F_I_LO: |
845 | case Lanai::AND_I_HI: |
846 | case Lanai::AND_I_LO: |
847 | case Lanai::OR_F_I_HI: |
848 | case Lanai::OR_F_I_LO: |
849 | case Lanai::OR_I_HI: |
850 | case Lanai::OR_I_LO: |
851 | case Lanai::SA_F_I: |
852 | case Lanai::SA_I: |
853 | case Lanai::SL_F_I: |
854 | case Lanai::SL_I: |
855 | case Lanai::SUBB_F_I_HI: |
856 | case Lanai::SUBB_F_I_LO: |
857 | case Lanai::SUBB_I_HI: |
858 | case Lanai::SUBB_I_LO: |
859 | case Lanai::SUB_F_I_HI: |
860 | case Lanai::SUB_F_I_LO: |
861 | case Lanai::SUB_I_HI: |
862 | case Lanai::SUB_I_LO: |
863 | case Lanai::XOR_F_I_HI: |
864 | case Lanai::XOR_F_I_LO: |
865 | case Lanai::XOR_I_HI: |
866 | case Lanai::XOR_I_LO: { |
867 | switch (OpNum) { |
868 | case 0: |
869 | // op: Rd |
870 | return 23; |
871 | case 1: |
872 | // op: Rs1 |
873 | return 18; |
874 | case 2: |
875 | // op: imm16 |
876 | return 0; |
877 | } |
878 | break; |
879 | } |
880 | case Lanai::LEADZ: |
881 | case Lanai::POPC: |
882 | case Lanai::TRAILZ: { |
883 | switch (OpNum) { |
884 | case 0: |
885 | // op: Rd |
886 | return 23; |
887 | case 1: |
888 | // op: Rs1 |
889 | return 18; |
890 | } |
891 | break; |
892 | } |
893 | case Lanai::STADDR: |
894 | case Lanai::STB_RI: |
895 | case Lanai::STH_RI: |
896 | case Lanai::SW_RI: { |
897 | switch (OpNum) { |
898 | case 0: |
899 | // op: Rd |
900 | return 23; |
901 | case 1: |
902 | // op: dst |
903 | return 0; |
904 | } |
905 | break; |
906 | } |
907 | case Lanai::STB_RR: |
908 | case Lanai::STH_RR: |
909 | case Lanai::SW_RR: { |
910 | switch (OpNum) { |
911 | case 0: |
912 | // op: Rd |
913 | return 23; |
914 | case 1: |
915 | // op: dst |
916 | return 3; |
917 | } |
918 | break; |
919 | } |
920 | case Lanai::SLI: { |
921 | switch (OpNum) { |
922 | case 0: |
923 | // op: Rd |
924 | return 23; |
925 | case 1: |
926 | // op: imm |
927 | return 0; |
928 | } |
929 | break; |
930 | } |
931 | case Lanai::MOVHI: { |
932 | switch (OpNum) { |
933 | case 0: |
934 | // op: Rd |
935 | return 23; |
936 | case 1: |
937 | // op: imm16 |
938 | return 0; |
939 | } |
940 | break; |
941 | } |
942 | case Lanai::LDADDR: |
943 | case Lanai::LDBs_RI: |
944 | case Lanai::LDBz_RI: |
945 | case Lanai::LDHs_RI: |
946 | case Lanai::LDHz_RI: |
947 | case Lanai::LDW_RI: { |
948 | switch (OpNum) { |
949 | case 0: |
950 | // op: Rd |
951 | return 23; |
952 | case 1: |
953 | // op: src |
954 | return 0; |
955 | } |
956 | break; |
957 | } |
958 | case Lanai::LDBs_RR: |
959 | case Lanai::LDBz_RR: |
960 | case Lanai::LDHs_RR: |
961 | case Lanai::LDHz_RR: |
962 | case Lanai::LDW_RR: |
963 | case Lanai::LDWz_RR: { |
964 | switch (OpNum) { |
965 | case 0: |
966 | // op: Rd |
967 | return 23; |
968 | case 1: |
969 | // op: src |
970 | return 3; |
971 | } |
972 | break; |
973 | } |
974 | case Lanai::BRIND_CC: |
975 | case Lanai::SCC: { |
976 | switch (OpNum) { |
977 | case 0: |
978 | // op: Rs1 |
979 | return 18; |
980 | case 1: |
981 | // op: DDDI |
982 | return 0; |
983 | } |
984 | break; |
985 | } |
986 | case Lanai::BRIND_CCA: { |
987 | switch (OpNum) { |
988 | case 0: |
989 | // op: Rs1 |
990 | return 18; |
991 | case 1: |
992 | // op: Rs2 |
993 | return 11; |
994 | case 2: |
995 | // op: DDDI |
996 | return 0; |
997 | } |
998 | break; |
999 | } |
1000 | case Lanai::SFSUB_F_RR: { |
1001 | switch (OpNum) { |
1002 | case 0: |
1003 | // op: Rs1 |
1004 | return 18; |
1005 | case 1: |
1006 | // op: Rs2 |
1007 | return 11; |
1008 | } |
1009 | break; |
1010 | } |
1011 | case Lanai::SFSUB_F_RI_HI: |
1012 | case Lanai::SFSUB_F_RI_LO: { |
1013 | switch (OpNum) { |
1014 | case 0: |
1015 | // op: Rs1 |
1016 | return 18; |
1017 | case 1: |
1018 | // op: imm16 |
1019 | return 0; |
1020 | } |
1021 | break; |
1022 | } |
1023 | case Lanai::JR: { |
1024 | switch (OpNum) { |
1025 | case 0: |
1026 | // op: Rs2 |
1027 | return 11; |
1028 | } |
1029 | break; |
1030 | } |
1031 | case Lanai::BRCC: { |
1032 | switch (OpNum) { |
1033 | case 0: |
1034 | // op: addr |
1035 | return 2; |
1036 | case 1: |
1037 | // op: DDDI |
1038 | return 0; |
1039 | } |
1040 | break; |
1041 | } |
1042 | case Lanai::BT: { |
1043 | switch (OpNum) { |
1044 | case 0: |
1045 | // op: addr |
1046 | return 2; |
1047 | } |
1048 | break; |
1049 | } |
1050 | case Lanai::BRR: { |
1051 | switch (OpNum) { |
1052 | case 1: |
1053 | // op: DDDI |
1054 | return 0; |
1055 | case 0: |
1056 | // op: imm16 |
1057 | return 2; |
1058 | } |
1059 | break; |
1060 | } |
1061 | } |
1062 | std::string msg; |
1063 | raw_string_ostream Msg(msg); |
1064 | Msg << "Not supported instr[opcode]: " << MI << "[" << OpNum << "]" ; |
1065 | report_fatal_error(Msg.str().c_str()); |
1066 | } |
1067 | |
1068 | #endif // GET_OPERAND_BIT_OFFSET |
1069 | |
1070 | |