[mips][microMIPS] Implement LB, LBE, LBU and LBUE 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 LB32_FM_MMR6 : MipsR6Inst {
137   bits<21> addr;
138   bits<5> rt;
139   bits<5> base = addr{20-16};
140   bits<16> offset = addr{15-0};
141
142   bits<32> Inst;
143
144   let Inst{31-26} = 0b000111;
145   let Inst{25-21} = rt;
146   let Inst{20-16} = base;
147   let Inst{15-0}  = offset;
148 }
149
150 class LBU32_FM_MMR6 : MipsR6Inst {
151   bits<21> addr;
152   bits<5> rt;
153   bits<5> base = addr{20-16};
154   bits<16> offset = addr{15-0};
155
156   bits<32> Inst;
157
158   let Inst{31-26} = 0b000101;
159   let Inst{25-21} = rt;
160   let Inst{20-16} = base;
161   let Inst{15-0}  = offset;
162 }
163
164 class POOL32C_LB_LBU_FM_MMR6<bits<3> funct> : MipsR6Inst {
165   bits<21> addr;
166   bits<5> rt;
167
168   bits<32> Inst;
169
170   let Inst{31-26} = 0b011000;
171   let Inst{25-21} = rt;
172   let Inst{20-16} = addr{20-16};
173   let Inst{15-12} = 0b0110;
174   let Inst{11-9} = funct;
175   let Inst{8-0}  = addr{8-0};
176 }
177
178 class SIGN_EXTEND_FM_MMR6<string instr_asm, bits<10> funct>
179     : MMR6Arch<instr_asm> {
180   bits<5> rd;
181   bits<5> rt;
182
183   bits<32> Inst;
184
185   let Inst{31-26} = 0b000000;
186   let Inst{25-21} = rd;
187   let Inst{20-16} = rt;
188   let Inst{15-6}  = funct;
189   let Inst{5-0}   = 0b111100;
190 }
191
192 class PCREL19_FM_MMR6<bits<2> funct> : MipsR6Inst {
193   bits<5> rt;
194   bits<19> imm;
195
196   bits<32> Inst;
197
198   let Inst{31-26} = 0b011110;
199   let Inst{25-21} = rt;
200   let Inst{20-19} = funct;
201   let Inst{18-0}  = imm;
202 }
203
204 class PCREL16_FM_MMR6<bits<5> funct> : MipsR6Inst {
205   bits<5> rt;
206   bits<16> imm;
207
208   bits<32> Inst;
209
210   let Inst{31-26} = 0b011110;
211   let Inst{25-21} = rt;
212   let Inst{20-16} = funct;
213   let Inst{15-0}  = imm;
214 }
215
216 class POOL32A_FM_MMR6<bits<10> funct> : MipsR6Inst {
217   bits<5> rd;
218   bits<5> rs;
219   bits<5> rt;
220
221   bits<32> Inst;
222
223   let Inst{31-26} = 0b000000;
224   let Inst{25-21} = rt;
225   let Inst{20-16} = rs;
226   let Inst{15-11} = rd;
227   let Inst{10}    = 0;
228   let Inst{9-0}   = funct;
229 }
230
231 class POOL32A_2R_FM_MMR6<bits<10> funct> : MipsR6Inst {
232   bits<5> rs;
233   bits<5> rt;
234
235   bits<32> Inst;
236
237   let Inst{31-26} = 0b000000;
238   let Inst{25-21} = rt;
239   let Inst{20-16} = rs;
240   let Inst{15-6}  = funct;
241   let Inst{5-0}   = 0b111100;
242 }
243
244 class SPECIAL_2R_FM_MMR6<bits<6> funct> : MipsR6Inst {
245   bits<5> rs;
246   bits<5> rt;
247
248   bits<32> Inst;
249
250   let Inst{31-26} = 0b000000;
251   let Inst{25-21} = rs;
252   let Inst{20-16} = 0b00000;
253   let Inst{15-11} = rt;
254   let Inst{10-6}  = 0b00001;
255   let Inst{5-0}   = funct;
256 }
257
258 class POOL32A_ALIGN_FM_MMR6<bits<6> funct> : MipsR6Inst {
259   bits<5> rd;
260   bits<5> rs;
261   bits<5> rt;
262   bits<2> bp;
263
264   bits<32> Inst;
265
266   let Inst{31-26} = 0b000000;
267   let Inst{25-21} = rs;
268   let Inst{20-16} = rt;
269   let Inst{15-11} = rd;
270   let Inst{10-9}  = bp;
271   let Inst{8-6}   = 0b000;
272   let Inst{5-0}   = funct;
273 }
274
275 class AUI_FM_MMR6 : MipsR6Inst {
276   bits<5> rs;
277   bits<5> rt;
278   bits<16> imm;
279
280   bits<32> Inst;
281
282   let Inst{31-26} = 0b000100;
283   let Inst{25-21} = rt;
284   let Inst{20-16} = rs;
285   let Inst{15-0} = imm;
286 }
287
288 class POOL32A_LSA_FM<bits<6> funct> : MipsR6Inst {
289   bits<5> rd;
290   bits<5> rs;
291   bits<5> rt;
292   bits<2> imm2;
293
294   bits<32> Inst;
295
296   let Inst{31-26} = 0b000000;
297   let Inst{25-21} = rt;
298   let Inst{20-16} = rs;
299   let Inst{15-11} = rd;
300   let Inst{10-9}  = imm2;
301   let Inst{8-6}   = 0b000;
302   let Inst{5-0}   = funct;
303 }
304
305 class SB32_SH32_STORE_FM_MMR6<bits<6> op> {
306   bits<5> rt;
307   bits<21> addr;
308   bits<5> base = addr{20-16};
309   bits<16> offset = addr{15-0};
310
311   bits<32> Inst;
312
313   let Inst{31-26} = op;
314   let Inst{25-21} = rt;
315   let Inst{20-16} = base;
316   let Inst{15-0}  = offset;
317 }
318
319 class POOL32C_STORE_EVA_FM_MMR6<bits<3> funct> {
320   bits<5> rt;
321   bits<21> addr;
322   bits<5> base = addr{20-16};
323   bits<9> offset = addr{8-0};
324
325   bits<32> Inst;
326
327   let Inst{31-26} = 0b011000;
328   let Inst{25-21} = rt;
329   let Inst{20-16} = base;
330   let Inst{15-12} = 0b1010;
331   let Inst{11-9}  = funct;
332   let Inst{8-0}   = offset;
333 }
334
335 class LOAD_WORD_EVA_FM_MMR6<bits<3> funct> {
336   bits<5> rt;
337   bits<21> addr;
338   bits<5> base = addr{20-16};
339   bits<9> offset = addr{8-0};
340
341   bits<32> Inst;
342
343   let Inst{31-26} = 0b011000;
344   let Inst{25-21} = rt;
345   let Inst{20-16} = base;
346   let Inst{15-12} = 0b0110;
347   let Inst{11-9}  = funct;
348   let Inst{8-0}   = offset;
349 }
350
351 class LOAD_WORD_FM_MMR6 {
352   bits<5> rt;
353   bits<21> addr;
354   bits<5> base = addr{20-16};
355   bits<16> offset = addr{15-0};
356
357   bits<32> Inst;
358
359   let Inst{31-26} = 0b111111;
360   let Inst{25-21} = rt;
361   let Inst{20-16} = base;
362   let Inst{15-0}  = offset;
363 }
364
365 class LOAD_UPPER_IMM_FM_MMR6 {
366   bits<5> rt;
367   bits<16> imm16;
368
369   bits<32> Inst;
370
371   let Inst{31-26} = 0b000100;
372   let Inst{25-21} = rt;
373   let Inst{20-16} = 0;
374   let Inst{15-0}  = imm16;
375 }
376
377 class CMP_BRANCH_1R_RT_OFF16_FM_MMR6<bits<6> funct> : MipsR6Inst {
378   bits<5> rt;
379   bits<16> offset;
380
381   bits<32> Inst;
382
383   let Inst{31-26} = funct;
384   let Inst{25-21} = rt;
385   let Inst{20-16} = 0b00000;
386   let Inst{15-0}  = offset;
387 }
388
389 class CMP_BRANCH_1R_BOTH_OFF16_FM_MMR6<bits<6> funct> : MipsR6Inst {
390   bits<5> rt;
391   bits<16> offset;
392
393   bits<32> Inst;
394
395   let Inst{31-26} = funct;
396   let Inst{25-21} = rt;
397   let Inst{20-16} = rt;
398   let Inst{15-0}  = offset;
399 }
400
401 class ERET_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
402   bits<32> Inst;
403
404   let Inst{31-26} = 0x00;
405   let Inst{25-16} = 0x00;
406   let Inst{15-6}  = 0x3cd;
407   let Inst{5-0}   = 0x3c;
408 }
409
410 class ERETNC_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
411   bits<32> Inst;
412
413   let Inst{31-26} = 0x00;
414   let Inst{25-17} = 0x00;
415   let Inst{16-16} = 0x01;
416   let Inst{15-6}  = 0x3cd;
417   let Inst{5-0}   = 0x3c;
418 }
419
420 class BREAK_MMR6_ENC<string instr_asm> : MMR6Arch<instr_asm> {
421   bits<10> code_1;
422   bits<10> code_2;
423   bits<32> Inst;
424   let Inst{31-26} = 0x0;
425   let Inst{25-16} = code_1;
426   let Inst{15-6}  = code_2;
427   let Inst{5-0}   = 0x07;
428 }
429
430 class BARRIER_MMR6_ENC<string instr_asm, bits<5> op> : MMR6Arch<instr_asm> {
431   bits<32> Inst;
432
433   let Inst{31-26} = 0x0;
434   let Inst{25-21} = 0x0;
435   let Inst{20-16} = 0x0;
436   let Inst{15-11} = op;
437   let Inst{10-6}  = 0x0;
438   let Inst{5-0}   = 0x0;
439 }
440
441 class EIDI_MMR6_ENC<string instr_asm, bits<10> funct> : MMR6Arch<instr_asm> {
442   bits<32> Inst;
443   bits<5> rt; // Actually rs but we're sharing code with the standard encodings which call it rt
444
445   let Inst{31-26} = 0x00;
446   let Inst{25-21} = 0x00;
447   let Inst{20-16} = rt;
448   let Inst{15-6}  = funct;
449   let Inst{5-0}   = 0x3c;
450 }
451
452 class SHIFT_MMR6_ENC<string instr_asm, bits<10> funct, bit rotate> : MMR6Arch<instr_asm> {
453   bits<5> rd;
454   bits<5> rt;
455   bits<5> shamt;
456
457   bits<32> Inst;
458
459   let Inst{31-26} = 0;
460   let Inst{25-21} = rd;
461   let Inst{20-16} = rt;
462   let Inst{15-11} = shamt;
463   let Inst{10}    = rotate;
464   let Inst{9-0}   = funct;
465 }
466
467 class SW32_FM_MMR6<string instr_asm, bits<6> op> : MMR6Arch<instr_asm> {
468   bits<5> rt;
469   bits<21> addr;
470
471   bits<32> Inst;
472
473   let Inst{31-26} = op;
474   let Inst{25-21} = rt;
475   let Inst{20-16} = addr{20-16};
476   let Inst{15-0}  = addr{15-0};
477 }
478
479 class POOL32C_SWE_FM_MMR6<string instr_asm, bits<6> op, bits<4> fmt,
480     bits<3> funct> : MMR6Arch<instr_asm> {
481   bits<5> rt;
482   bits<21> addr;
483   bits<5> base = addr{20-16};
484   bits<9> offset = addr{8-0};
485
486   bits<32> Inst;
487
488   let Inst{31-26} = op;
489   let Inst{25-21} = rt;
490   let Inst{20-16} = base;
491   let Inst{15-12} = fmt;
492   let Inst{11-9} = funct;
493   let Inst{8-0}  = offset;
494 }
495
496 class POOL32F_ARITH_FM_MMR6<string instr_asm, bits<2> fmt, bits<8> funct>
497     : MMR6Arch<instr_asm>, MipsR6Inst {
498   bits<5> ft;
499   bits<5> fs;
500   bits<5> fd;
501
502   bits<32> Inst;
503
504   let Inst{31-26} = 0b010101;
505   let Inst{25-21} = ft;
506   let Inst{20-16} = fs;
507   let Inst{15-11} = fd;
508   let Inst{10}    = 0;
509   let Inst{9-8}   = fmt;
510   let Inst{7-0}   = funct;
511 }
512
513 class POOL32F_ARITHF_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
514     : MMR6Arch<instr_asm>, MipsR6Inst {
515   bits<5> ft;
516   bits<5> fs;
517   bits<5> fd;
518
519   bits<32> Inst;
520
521   let Inst{31-26} = 0b010101;
522   let Inst{25-21} = ft;
523   let Inst{20-16} = fs;
524   let Inst{15-11} = fd;
525   let Inst{10-9}  = fmt;
526   let Inst{8-0}   = funct;
527 }
528
529 class POOL32F_MOV_NEG_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
530     : MMR6Arch<instr_asm>, MipsR6Inst {
531   bits<5> ft;
532   bits<5> fs;
533
534   bits<32> Inst;
535
536   let Inst{31-26} = 0b010101;
537   let Inst{25-21} = ft;
538   let Inst{20-16} = fs;
539   let Inst{15}    = 0;
540   let Inst{14-13} = fmt;
541   let Inst{12-6}  = funct;
542   let Inst{5-0}   = 0b111011;
543 }
544
545 class POOL32F_MINMAX_FM<string instr_asm, bits<2> fmt, bits<9> funct>
546     : MMR6Arch<instr_asm>, MipsR6Inst {
547   bits<5> ft;
548   bits<5> fs;
549   bits<5> fd;
550
551   bits<32> Inst;
552
553   let Inst{31-26} = 0b010101;
554   let Inst{25-21} = ft;
555   let Inst{20-16} = fs;
556   let Inst{15-11} = fd;
557   let Inst{10-9} = fmt;
558   let Inst{8-0} = funct;
559 }
560
561 class POOL32F_CMP_FM<string instr_asm, bits<6> format, FIELD_CMP_COND Cond>
562     : MMR6Arch<instr_asm>, MipsR6Inst {
563   bits<5> ft;
564   bits<5> fs;
565   bits<5> fd;
566
567   bits<32> Inst;
568
569   let Inst{31-26} = 0b010101;
570   let Inst{25-21} = ft;
571   let Inst{20-16} = fs;
572   let Inst{15-11} = fd;
573   let Inst{10-6} = Cond.Value;
574   let Inst{5-0} = format;
575 }
576
577 class POOL32F_CVT_LW_FM<string instr_asm, bit fmt, bits<8> funct>
578     : MMR6Arch<instr_asm>, MipsR6Inst {
579   bits<5> ft;
580   bits<5> fs;
581
582   bits<32> Inst;
583   let Inst{31-26} = 0b010101;
584   let Inst{25-21} = ft;
585   let Inst{20-16} = fs;
586   let Inst{15} = 0;
587   let Inst{14} = fmt;
588   let Inst{13-6} = funct;
589   let Inst{5-0} = 0b111011;
590 }
591
592 class POOL32F_CVT_DS_FM<string instr_asm, bits<2> fmt, bits<7> funct>
593     : MMR6Arch<instr_asm>, MipsR6Inst {
594   bits<5> ft;
595   bits<5> fs;
596
597   bits<32> Inst;
598   let Inst{31-26} = 0b010101;
599   let Inst{25-21} = ft;
600   let Inst{20-16} = fs;
601   let Inst{15} = 0;
602   let Inst{14-13} = fmt;
603   let Inst{12-6} = funct;
604   let Inst{5-0} = 0b111011;
605 }
606
607 class POOL32F_ABS_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
608     : MMR6Arch<instr_asm>, MipsR6Inst {
609   bits<5> ft;
610   bits<5> fs;
611
612   bits<32> Inst;
613
614   let Inst{31-26} = 0b010101;
615   let Inst{25-21} = ft;
616   let Inst{20-16} = fs;
617   let Inst{15}    = 0;
618   let Inst{14-13} = fmt;
619   let Inst{12-6}  = funct;
620   let Inst{5-0}   = 0b111011;
621 }
622
623 class POOL32F_MATH_FM_MMR6<string instr_asm, bits<1> fmt, bits<8> funct>
624     : MMR6Arch<instr_asm>, MipsR6Inst {
625   bits<5> ft;
626   bits<5> fs;
627
628   bits<32> Inst;
629
630   let Inst{31-26} = 0b010101;
631   let Inst{25-21} = ft;
632   let Inst{20-16} = fs;
633   let Inst{15}    = 0;
634   let Inst{14}    = fmt;
635   let Inst{13-6}  = funct;
636   let Inst{5-0}   = 0b111011;
637 }
638
639 class POOL16A_ADDU16_FM_MMR6 : MicroMipsR6Inst16 {
640   bits<3> rs;
641   bits<3> rt;
642   bits<3> rd;
643
644   bits<16> Inst;
645
646   let Inst{15-10} = 0b000001;
647   let Inst{9-7}   = rs;
648   let Inst{6-4}   = rt;
649   let Inst{3-1}   = rd;
650   let Inst{0}     = 0;
651 }
652
653 class POOL16C_AND16_FM_MMR6 : MicroMipsR6Inst16 {
654   bits<3> rt;
655   bits<3> rs;
656
657   bits<16> Inst;
658
659   let Inst{15-10} = 0b010001;
660   let Inst{9-7}   = rt;
661   let Inst{6-4}   = rs;
662   let Inst{3-0}   = 0b0001;
663 }
664
665 class POOL16C_NOT16_FM_MMR6 : MicroMipsR6Inst16 {
666   bits<3> rt;
667   bits<3> rs;
668
669   bits<16> Inst;
670
671   let Inst{15-10} = 0x11;
672   let Inst{9-7}   = rt;
673   let Inst{6-4}   = rs;
674   let Inst{3-0}   = 0b0000;
675 }
676
677 class POOL16C_OR16_XOR16_FM_MMR6<bits<4> op> {
678   bits<3> rt;
679   bits<3> rs;
680
681   bits<16> Inst;
682
683   let Inst{15-10} = 0b010001;
684   let Inst{9-7}   = rt;
685   let Inst{6-4}   = rs;
686   let Inst{3-0}   = op;
687 }
688
689 class POOL16C_BREAKPOINT_FM_MMR6<bits<6> op> {
690   bits<4> code_;
691   bits<16> Inst;
692
693   let Inst{15-10} = 0b010001;
694   let Inst{9-6}   = code_;
695   let Inst{5-0}   = op;
696 }
697
698 class POOL16A_SUBU16_FM_MMR6 {
699   bits<3> rs;
700   bits<3> rt;
701   bits<3> rd;
702
703   bits<16> Inst;
704
705   let Inst{15-10} = 0b000001;
706   let Inst{9-7}   = rs;
707   let Inst{6-4}   = rt;
708   let Inst{3-1}   = rd;
709   let Inst{0}     = 0b1;
710 }
711
712 class POOL32A_WRPGPR_WSBH_FM_MMR6<bits<10> funct> : MipsR6Inst {
713   bits<5> rt;
714   bits<5> rs;
715
716   bits<32> Inst;
717
718   let Inst{31-26} = 0x00;
719   let Inst{25-21} = rt;
720   let Inst{20-16} = rs;
721   let Inst{15-6}  = funct;
722   let Inst{5-0}   = 0x3c;
723 }