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