[mips][microMIPS] Implement JALRC16, JRCADDIUSP and JRC16 instructions
[oota-llvm.git] / lib / Target / Mips / MicroMips32r6InstrFormats.td
1 //=- MicroMips32r6InstrFormats.td - Mips32r6 Instruction Formats -*- tablegen -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes microMIPS32r6 instruction formats.
11 //
12 //===----------------------------------------------------------------------===//
13
14 class MMR6Arch<string opstr> {
15   string Arch = "micromipsr6";
16   string BaseOpcode = opstr;
17 }
18
19 // Class used for microMIPS32r6 and microMIPS64r6 instructions.
20 class MicroMipsR6Inst16 : PredicateControl {
21   string DecoderNamespace = "MicroMipsR6";
22   let InsnPredicates = [HasMicroMips32r6];
23 }
24
25 class BC16_FM_MM16R6 {
26   bits<10> offset;
27
28   bits<16> Inst;
29
30   let Inst{15-10} = 0x33;
31   let Inst{9-0}   = offset;
32 }
33
34 class BEQZC_BNEZC_FM_MM16R6<bits<6> op> : MicroMipsR6Inst16 {
35   bits<3> rs;
36   bits<7> offset;
37
38   bits<16> Inst;
39
40   let Inst{15-10} = op;
41   let Inst{9-7}   = rs;
42   let Inst{6-0}   = offset;
43 }
44
45 class POOL16C_JALRC_FM_MM16R6<bits<5> op> {
46   bits<5> rs;
47
48   bits<16> Inst;
49
50   let Inst{15-10} = 0x11;
51   let Inst{9-5}   = rs;
52   let Inst{4-0}   = op;
53 }
54
55 class POOL16C_JRCADDIUSP_FM_MM16R6<bits<5> op> {
56   bits<5> imm;
57
58   bits<16> Inst;
59
60   let Inst{15-10} = 0x11;
61   let Inst{9-5}   = imm;
62   let Inst{4-0}   = op;
63 }
64
65 class POOL32A_BITSWAP_FM_MMR6<bits<6> funct> : MipsR6Inst {
66   bits<5> rd;
67   bits<5> rt;
68
69   bits<32> Inst;
70
71   let Inst{31-26} = 0b000000;
72   let Inst{25-21} = rt;
73   let Inst{20-16} = rd;
74   let Inst{15-12} = 0b0000;
75   let Inst{11-6} = funct;
76   let Inst{5-0} = 0b111100;
77 }
78
79 class CACHE_PREF_FM_MMR6<bits<6> opgroup, bits<4> funct> : MipsR6Inst {
80   bits<21> addr;
81   bits<5> hint;
82
83   bits<32> Inst;
84
85   let Inst{31-26} = opgroup;
86   let Inst{25-21} = hint;
87   let Inst{20-16} = addr{20-16};
88   let Inst{15-12} = funct;
89   let Inst{11-0}  = addr{11-0};
90 }
91
92 class ARITH_FM_MMR6<string instr_asm, bits<10> funct> : MMR6Arch<instr_asm> {
93   bits<5> rd;
94   bits<5> rt;
95   bits<5> rs;
96
97   bits<32> Inst;
98
99   let Inst{31-26} = 0;
100   let Inst{25-21} = rt;
101   let Inst{20-16} = rs;
102   let Inst{15-11} = rd;
103   let Inst{10}    = 0;
104   let Inst{9-0}   = funct;
105 }
106
107 class ADDI_FM_MMR6<string instr_asm, bits<6> op> : MMR6Arch<instr_asm> {
108   bits<5>  rt;
109   bits<5>  rs;
110   bits<16> imm16;
111
112   bits<32> Inst;
113
114   let Inst{31-26} = op;
115   let Inst{25-21} = rt;
116   let Inst{20-16} = rs;
117   let Inst{15-0}  = imm16;
118 }
119
120 class POOL32C_ST_EVA_FM_MMR6<bits<6> op, bits<3> funct> : MipsR6Inst {
121   bits<21> addr;
122   bits<5> hint;
123   bits<5> base = addr{20-16};
124   bits<9> offset = addr{8-0};
125
126   bits<32> Inst;
127
128   let Inst{31-26} = op;
129   let Inst{25-21} = hint;
130   let Inst{20-16} = base;
131   let Inst{15-12} = 0b1010;
132   let Inst{11-9} = funct;
133   let Inst{8-0}  = offset;
134 }
135
136 class SIGN_EXTEND_FM_MMR6<string instr_asm, bits<10> funct>
137     : MMR6Arch<instr_asm> {
138   bits<5> rd;
139   bits<5> rt;
140
141   bits<32> Inst;
142
143   let Inst{31-26} = 0b000000;
144   let Inst{25-21} = rd;
145   let Inst{20-16} = rt;
146   let Inst{15-6}  = funct;
147   let Inst{5-0}   = 0b111100;
148 }
149
150 class PCREL19_FM_MMR6<bits<2> funct> : MipsR6Inst {
151   bits<5> rt;
152   bits<19> imm;
153
154   bits<32> Inst;
155
156   let Inst{31-26} = 0b011110;
157   let Inst{25-21} = rt;
158   let Inst{20-19} = funct;
159   let Inst{18-0}  = imm;
160 }
161
162 class PCREL16_FM_MMR6<bits<5> funct> : MipsR6Inst {
163   bits<5> rt;
164   bits<16> imm;
165
166   bits<32> Inst;
167
168   let Inst{31-26} = 0b011110;
169   let Inst{25-21} = rt;
170   let Inst{20-16} = funct;
171   let Inst{15-0}  = imm;
172 }
173
174 class POOL32A_FM_MMR6<bits<10> funct> : MipsR6Inst {
175   bits<5> rd;
176   bits<5> rs;
177   bits<5> rt;
178
179   bits<32> Inst;
180
181   let Inst{31-26} = 0b000000;
182   let Inst{25-21} = rt;
183   let Inst{20-16} = rs;
184   let Inst{15-11} = rd;
185   let Inst{10}    = 0;
186   let Inst{9-0}   = funct;
187 }
188
189 class POOL32A_2R_FM_MMR6<bits<10> funct> : MipsR6Inst {
190   bits<5> rs;
191   bits<5> rt;
192
193   bits<32> Inst;
194
195   let Inst{31-26} = 0b000000;
196   let Inst{25-21} = rt;
197   let Inst{20-16} = rs;
198   let Inst{15-6}  = funct;
199   let Inst{5-0}   = 0b111100;
200 }
201
202 class SPECIAL_2R_FM_MMR6<bits<6> funct> : MipsR6Inst {
203   bits<5> rs;
204   bits<5> rt;
205
206   bits<32> Inst;
207
208   let Inst{31-26} = 0b000000;
209   let Inst{25-21} = rs;
210   let Inst{20-16} = 0b00000;
211   let Inst{15-11} = rt;
212   let Inst{10-6}  = 0b00001;
213   let Inst{5-0}   = funct;
214 }
215
216 class POOL32A_ALIGN_FM_MMR6<bits<6> funct> : MipsR6Inst {
217   bits<5> rd;
218   bits<5> rs;
219   bits<5> rt;
220   bits<2> bp;
221
222   bits<32> Inst;
223
224   let Inst{31-26} = 0b000000;
225   let Inst{25-21} = rs;
226   let Inst{20-16} = rt;
227   let Inst{15-11} = rd;
228   let Inst{10-9}  = bp;
229   let Inst{8-6}   = 0b000;
230   let Inst{5-0}   = funct;
231 }
232
233 class AUI_FM_MMR6 : MipsR6Inst {
234   bits<5> rs;
235   bits<5> rt;
236   bits<16> imm;
237
238   bits<32> Inst;
239
240   let Inst{31-26} = 0b000100;
241   let Inst{25-21} = rt;
242   let Inst{20-16} = rs;
243   let Inst{15-0} = imm;
244 }
245
246 class POOL32A_LSA_FM<bits<6> funct> : MipsR6Inst {
247   bits<5> rd;
248   bits<5> rs;
249   bits<5> rt;
250   bits<2> imm2;
251
252   bits<32> Inst;
253
254   let Inst{31-26} = 0b000000;
255   let Inst{25-21} = rt;
256   let Inst{20-16} = rs;
257   let Inst{15-11} = rd;
258   let Inst{10-9}  = imm2;
259   let Inst{8-6}   = 0b000;
260   let Inst{5-0}   = funct;
261 }
262
263 class SB32_SH32_STORE_FM_MMR6<bits<6> op> {
264   bits<5> rt;
265   bits<21> addr;
266   bits<5> base = addr{20-16};
267   bits<16> offset = addr{15-0};
268
269   bits<32> Inst;
270
271   let Inst{31-26} = op;
272   let Inst{25-21} = rt;
273   let Inst{20-16} = base;
274   let Inst{15-0}  = offset;
275 }
276
277 class POOL32C_STORE_EVA_FM_MMR6<bits<3> funct> {
278   bits<5> rt;
279   bits<21> addr;
280   bits<5> base = addr{20-16};
281   bits<9> offset = addr{8-0};
282
283   bits<32> Inst;
284
285   let Inst{31-26} = 0b011000;
286   let Inst{25-21} = rt;
287   let Inst{20-16} = base;
288   let Inst{15-12} = 0b1010;
289   let Inst{11-9}  = funct;
290   let Inst{8-0}   = offset;
291 }
292
293 class LOAD_WORD_EVA_FM_MMR6<bits<3> funct> {
294   bits<5> rt;
295   bits<21> addr;
296   bits<5> base = addr{20-16};
297   bits<9> offset = addr{8-0};
298
299   bits<32> Inst;
300
301   let Inst{31-26} = 0b011000;
302   let Inst{25-21} = rt;
303   let Inst{20-16} = base;
304   let Inst{15-12} = 0b0110;
305   let Inst{11-9}  = funct;
306   let Inst{8-0}   = offset;
307 }
308
309 class LOAD_WORD_FM_MMR6 {
310   bits<5> rt;
311   bits<21> addr;
312   bits<5> base = addr{20-16};
313   bits<16> offset = addr{15-0};
314
315   bits<32> Inst;
316
317   let Inst{31-26} = 0b111111;
318   let Inst{25-21} = rt;
319   let Inst{20-16} = base;
320   let Inst{15-0}  = offset;
321 }
322
323 class LOAD_UPPER_IMM_FM_MMR6 {
324   bits<5> rt;
325   bits<16> imm16;
326
327   bits<32> Inst;
328
329   let Inst{31-26} = 0b000100;
330   let Inst{25-21} = rt;
331   let Inst{20-16} = 0;
332   let Inst{15-0}  = imm16;
333 }
334
335 class CMP_BRANCH_1R_RT_OFF16_FM_MMR6<bits<6> funct> : MipsR6Inst {
336   bits<5> rt;
337   bits<16> offset;
338
339   bits<32> Inst;
340
341   let Inst{31-26} = funct;
342   let Inst{25-21} = rt;
343   let Inst{20-16} = 0b00000;
344   let Inst{15-0}  = offset;
345 }
346
347 class CMP_BRANCH_1R_BOTH_OFF16_FM_MMR6<bits<6> funct> : MipsR6Inst {
348   bits<5> rt;
349   bits<16> offset;
350
351   bits<32> Inst;
352
353   let Inst{31-26} = funct;
354   let Inst{25-21} = rt;
355   let Inst{20-16} = rt;
356   let Inst{15-0}  = offset;
357 }
358
359 class ERET_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
360   bits<32> Inst;
361
362   let Inst{31-26} = 0x00;
363   let Inst{25-16} = 0x00;
364   let Inst{15-6}  = 0x3cd;
365   let Inst{5-0}   = 0x3c;
366 }
367
368 class ERETNC_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
369   bits<32> Inst;
370
371   let Inst{31-26} = 0x00;
372   let Inst{25-17} = 0x00;
373   let Inst{16-16} = 0x01;
374   let Inst{15-6}  = 0x3cd;
375   let Inst{5-0}   = 0x3c;
376 }
377
378 class BREAK_MMR6_ENC<string instr_asm> : MMR6Arch<instr_asm> {
379   bits<10> code_1;
380   bits<10> code_2;
381   bits<32> Inst;
382   let Inst{31-26} = 0x0;
383   let Inst{25-16} = code_1;
384   let Inst{15-6}  = code_2;
385   let Inst{5-0}   = 0x07;
386 }
387
388 class BARRIER_MMR6_ENC<string instr_asm, bits<5> op> : MMR6Arch<instr_asm> {
389   bits<32> Inst;
390
391   let Inst{31-26} = 0x0;
392   let Inst{25-21} = 0x0;
393   let Inst{20-16} = 0x0;
394   let Inst{15-11} = op;
395   let Inst{10-6}  = 0x0;
396   let Inst{5-0}   = 0x0;
397 }
398
399 class EIDI_MMR6_ENC<string instr_asm, bits<10> funct> : MMR6Arch<instr_asm> {
400   bits<32> Inst;
401   bits<5> rt; // Actually rs but we're sharing code with the standard encodings which call it rt
402
403   let Inst{31-26} = 0x00;
404   let Inst{25-21} = 0x00;
405   let Inst{20-16} = rt;
406   let Inst{15-6}  = funct;
407   let Inst{5-0}   = 0x3c;
408 }
409
410 class SHIFT_MMR6_ENC<string instr_asm, bits<10> funct, bit rotate> : MMR6Arch<instr_asm> {
411   bits<5> rd;
412   bits<5> rt;
413   bits<5> shamt;
414
415   bits<32> Inst;
416
417   let Inst{31-26} = 0;
418   let Inst{25-21} = rd;
419   let Inst{20-16} = rt;
420   let Inst{15-11} = shamt;
421   let Inst{10}    = rotate;
422   let Inst{9-0}   = funct;
423 }
424
425 class SW32_FM_MMR6<string instr_asm, bits<6> op> : MMR6Arch<instr_asm> {
426   bits<5> rt;
427   bits<21> addr;
428
429   bits<32> Inst;
430
431   let Inst{31-26} = op;
432   let Inst{25-21} = rt;
433   let Inst{20-16} = addr{20-16};
434   let Inst{15-0}  = addr{15-0};
435 }
436
437 class POOL32C_SWE_FM_MMR6<string instr_asm, bits<6> op, bits<4> fmt,
438     bits<3> funct> : MMR6Arch<instr_asm> {
439   bits<5> rt;
440   bits<21> addr;
441   bits<5> base = addr{20-16};
442   bits<9> offset = addr{8-0};
443
444   bits<32> Inst;
445
446   let Inst{31-26} = op;
447   let Inst{25-21} = rt;
448   let Inst{20-16} = base;
449   let Inst{15-12} = fmt;
450   let Inst{11-9} = funct;
451   let Inst{8-0}  = offset;
452 }
453
454 class POOL32F_ARITH_FM_MMR6<string instr_asm, bits<2> fmt, bits<8> funct>
455     : MMR6Arch<instr_asm>, MipsR6Inst {
456   bits<5> ft;
457   bits<5> fs;
458   bits<5> fd;
459
460   bits<32> Inst;
461
462   let Inst{31-26} = 0b010101;
463   let Inst{25-21} = ft;
464   let Inst{20-16} = fs;
465   let Inst{15-11} = fd;
466   let Inst{10}    = 0;
467   let Inst{9-8}   = fmt;
468   let Inst{7-0}   = funct;
469 }
470
471 class POOL32F_ARITHF_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
472     : MMR6Arch<instr_asm>, MipsR6Inst {
473   bits<5> ft;
474   bits<5> fs;
475   bits<5> fd;
476
477   bits<32> Inst;
478
479   let Inst{31-26} = 0b010101;
480   let Inst{25-21} = ft;
481   let Inst{20-16} = fs;
482   let Inst{15-11} = fd;
483   let Inst{10-9}  = fmt;
484   let Inst{8-0}   = funct;
485 }
486
487 class POOL32F_MOV_NEG_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
488     : MMR6Arch<instr_asm>, MipsR6Inst {
489   bits<5> ft;
490   bits<5> fs;
491
492   bits<32> Inst;
493
494   let Inst{31-26} = 0b010101;
495   let Inst{25-21} = ft;
496   let Inst{20-16} = fs;
497   let Inst{15}    = 0;
498   let Inst{14-13} = fmt;
499   let Inst{12-6}  = funct;
500   let Inst{5-0}   = 0b111011;
501 }
502
503 class POOL32F_MINMAX_FM<string instr_asm, bits<2> fmt, bits<9> funct>
504     : MMR6Arch<instr_asm>, MipsR6Inst {
505   bits<5> ft;
506   bits<5> fs;
507   bits<5> fd;
508
509   bits<32> Inst;
510
511   let Inst{31-26} = 0b010101;
512   let Inst{25-21} = ft;
513   let Inst{20-16} = fs;
514   let Inst{15-11} = fd;
515   let Inst{10-9} = fmt;
516   let Inst{8-0} = funct;
517 }
518
519 class POOL32F_CMP_FM<string instr_asm, bits<6> format, FIELD_CMP_COND Cond>
520     : MMR6Arch<instr_asm>, MipsR6Inst {
521   bits<5> ft;
522   bits<5> fs;
523   bits<5> fd;
524
525   bits<32> Inst;
526
527   let Inst{31-26} = 0b010101;
528   let Inst{25-21} = ft;
529   let Inst{20-16} = fs;
530   let Inst{15-11} = fd;
531   let Inst{10-6} = Cond.Value;
532   let Inst{5-0} = format;
533 }
534
535 class POOL32F_CVT_LW_FM<string instr_asm, bit fmt, bits<8> funct>
536     : MMR6Arch<instr_asm>, MipsR6Inst {
537   bits<5> ft;
538   bits<5> fs;
539
540   bits<32> Inst;
541   let Inst{31-26} = 0b010101;
542   let Inst{25-21} = ft;
543   let Inst{20-16} = fs;
544   let Inst{15} = 0;
545   let Inst{14} = fmt;
546   let Inst{13-6} = funct;
547   let Inst{5-0} = 0b111011;
548 }
549
550 class POOL32F_CVT_DS_FM<string instr_asm, bits<2> fmt, bits<7> funct>
551     : MMR6Arch<instr_asm>, MipsR6Inst {
552   bits<5> ft;
553   bits<5> fs;
554
555   bits<32> Inst;
556   let Inst{31-26} = 0b010101;
557   let Inst{25-21} = ft;
558   let Inst{20-16} = fs;
559   let Inst{15} = 0;
560   let Inst{14-13} = fmt;
561   let Inst{12-6} = funct;
562   let Inst{5-0} = 0b111011;
563 }
564
565 class POOL32F_ABS_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
566     : MMR6Arch<instr_asm>, MipsR6Inst {
567   bits<5> ft;
568   bits<5> fs;
569
570   bits<32> Inst;
571
572   let Inst{31-26} = 0b010101;
573   let Inst{25-21} = ft;
574   let Inst{20-16} = fs;
575   let Inst{15}    = 0;
576   let Inst{14-13} = fmt;
577   let Inst{12-6}  = funct;
578   let Inst{5-0}   = 0b111011;
579 }
580
581 class POOL32F_MATH_FM_MMR6<string instr_asm, bits<1> fmt, bits<8> funct>
582     : MMR6Arch<instr_asm>, MipsR6Inst {
583   bits<5> ft;
584   bits<5> fs;
585
586   bits<32> Inst;
587
588   let Inst{31-26} = 0b010101;
589   let Inst{25-21} = ft;
590   let Inst{20-16} = fs;
591   let Inst{15}    = 0;
592   let Inst{14}    = fmt;
593   let Inst{13-6}  = funct;
594   let Inst{5-0}   = 0b111011;
595 }
596
597 class POOL16A_ADDU16_FM_MMR6 : MicroMipsR6Inst16 {
598   bits<3> rs;
599   bits<3> rt;
600   bits<3> rd;
601
602   bits<16> Inst;
603
604   let Inst{15-10} = 0b000001;
605   let Inst{9-7}   = rs;
606   let Inst{6-4}   = rt;
607   let Inst{3-1}   = rd;
608   let Inst{0}     = 0;
609 }
610
611 class POOL16C_AND16_FM_MMR6 : MicroMipsR6Inst16 {
612   bits<3> rt;
613   bits<3> rs;
614
615   bits<16> Inst;
616
617   let Inst{15-10} = 0b010001;
618   let Inst{9-7}   = rt;
619   let Inst{6-4}   = rs;
620   let Inst{3-0}   = 0b0001;
621 }
622
623 class POOL16C_NOT16_FM_MMR6 : MicroMipsR6Inst16 {
624   bits<3> rt;
625   bits<3> rs;
626
627   bits<16> Inst;
628
629   let Inst{15-10} = 0x11;
630   let Inst{9-7}   = rt;
631   let Inst{6-4}   = rs;
632   let Inst{3-0}   = 0b0000;
633 }
634
635 class POOL16C_OR16_FM_MMR6 : MicroMipsR6Inst16 {
636   bits<3> rt;
637   bits<3> rs;
638
639   bits<16> Inst;
640
641   let Inst{15-10} = 0b010001;
642   let Inst{9-7}   = rt;
643   let Inst{6-4}   = rs;
644   let Inst{3-0}   = 0b1001;
645 }
646
647 class POOL32A_WRPGPR_WSBH_FM_MMR6<bits<10> funct> : MipsR6Inst {
648   bits<5> rt;
649   bits<5> rs;
650
651   bits<32> Inst;
652
653   let Inst{31-26} = 0x00;
654   let Inst{25-21} = rt;
655   let Inst{20-16} = rs;
656   let Inst{15-6}  = funct;
657   let Inst{5-0}   = 0x3c;
658 }