[mips] Improve the error messages given by MipsAsmParser.
[oota-llvm.git] / lib / Target / Mips / MicroMipsInstrFormats.td
1 //===----------------------------------------------------------------------===//
2 // MicroMIPS Base Classes
3 //===----------------------------------------------------------------------===//
4
5 //
6 // Base class for MicroMips instructions.
7 // This class does not depend on the instruction size.
8 //
9 class MicroMipsInstBase<dag outs, dag ins, string asmstr, list<dag> pattern,
10                         InstrItinClass itin, Format f> : Instruction
11 {
12   let Namespace = "Mips";
13   let DecoderNamespace = "MicroMips";
14
15   let OutOperandList = outs;
16   let InOperandList  = ins;
17
18   let AsmString   = asmstr;
19   let Pattern     = pattern;
20   let Itinerary   = itin;
21
22   let Predicates = [InMicroMips];
23
24   Format Form = f;
25 }
26
27 //
28 // Base class for MicroMIPS 16-bit instructions.
29 //
30 class MicroMipsInst16<dag outs, dag ins, string asmstr, list<dag> pattern,
31                InstrItinClass itin, Format f> :
32   MicroMipsInstBase<outs, ins, asmstr, pattern, itin, f>
33 {
34   let Size = 2;
35   field bits<16> Inst;
36   field bits<16> SoftFail = 0;
37   bits<6> Opcode = 0x0;
38 }
39
40 //===----------------------------------------------------------------------===//
41 // MicroMIPS 16-bit Instruction Formats
42 //===----------------------------------------------------------------------===//
43
44 class MOVE_FM_MM16<bits<6> funct> {
45   bits<5> rs;
46   bits<5> rd;
47
48   bits<16> Inst;
49
50   let Inst{15-10} = funct;
51   let Inst{9-5}   = rd;
52   let Inst{4-0}   = rs;
53 }
54
55 class JALR_FM_MM16<bits<5> op> {
56   bits<5> rs;
57
58   bits<16> Inst;
59
60   let Inst{15-10} = 0x11;
61   let Inst{9-5}   = op;
62   let Inst{4-0}   = rs;
63 }
64
65 class MFHILO_FM_MM16<bits<5> funct> {
66   bits<5> rd;
67
68   bits<16> Inst;
69
70   let Inst{15-10} = 0x11;
71   let Inst{9-5}   = funct;
72   let Inst{4-0}   = rd;
73 }
74
75 class JRADDIUSP_FM_MM16<bits<5> op> {
76   bits<5> rs;
77   bits<5> imm;
78
79   bits<16> Inst;
80
81   let Inst{15-10} = 0x11;
82   let Inst{9-5}   = op;
83   let Inst{4-0}   = imm;
84 }
85
86 //===----------------------------------------------------------------------===//
87 // MicroMIPS 32-bit Instruction Formats
88 //===----------------------------------------------------------------------===//
89
90 class MMArch {
91   string Arch = "micromips";
92   list<dag> Pattern = [];
93 }
94
95 class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
96   bits<5> rt;
97   bits<5> rs;
98   bits<5> rd;
99
100   bits<32> Inst;
101
102   let Inst{31-26} = op;
103   let Inst{25-21} = rt;
104   let Inst{20-16} = rs;
105   let Inst{15-11} = rd;
106   let Inst{10}    = 0;
107   let Inst{9-0}   = funct;
108 }
109
110 class ADDI_FM_MM<bits<6> op> : MMArch {
111   bits<5>  rs;
112   bits<5>  rt;
113   bits<16> imm16;
114
115   bits<32> Inst;
116
117   let Inst{31-26} = op;
118   let Inst{25-21} = rt;
119   let Inst{20-16} = rs;
120   let Inst{15-0}  = imm16;
121 }
122
123 class SLTI_FM_MM<bits<6> op> : MMArch {
124   bits<5> rt;
125   bits<5> rs;
126   bits<16> imm16;
127
128   bits<32> Inst;
129
130   let Inst{31-26} = op;
131   let Inst{25-21} = rt;
132   let Inst{20-16} = rs;
133   let Inst{15-0}  = imm16;
134 }
135
136 class LUI_FM_MM : MMArch {
137   bits<5> rt;
138   bits<16> imm16;
139
140   bits<32> Inst;
141
142   let Inst{31-26} = 0x10;
143   let Inst{25-21} = 0xd;
144   let Inst{20-16} = rt;
145   let Inst{15-0}  = imm16;
146 }
147
148 class MULT_FM_MM<bits<10> funct> : MMArch {
149   bits<5>  rs;
150   bits<5>  rt;
151
152   bits<32> Inst;
153
154   let Inst{31-26} = 0x00;
155   let Inst{25-21} = rt;
156   let Inst{20-16} = rs;
157   let Inst{15-6}  = funct;
158   let Inst{5-0}   = 0x3c;
159 }
160
161 class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
162   bits<5> rd;
163   bits<5> rt;
164   bits<5> shamt;
165
166   bits<32> Inst;
167
168   let Inst{31-26} = 0;
169   let Inst{25-21} = rd;
170   let Inst{20-16} = rt;
171   let Inst{15-11} = shamt;
172   let Inst{10}    = rotate;
173   let Inst{9-0}   = funct;
174 }
175
176 class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
177   bits<5> rd;
178   bits<5> rt;
179   bits<5> rs;
180
181   bits<32> Inst;
182
183   let Inst{31-26} = 0;
184   let Inst{25-21} = rt;
185   let Inst{20-16} = rs;
186   let Inst{15-11} = rd;
187   let Inst{10}    = rotate;
188   let Inst{9-0}   = funct;
189 }
190
191 class LW_FM_MM<bits<6> op> : MMArch {
192   bits<5> rt;
193   bits<21> addr;
194
195   bits<32> Inst;
196
197   let Inst{31-26} = op;
198   let Inst{25-21} = rt;
199   let Inst{20-16} = addr{20-16};
200   let Inst{15-0}  = addr{15-0};
201 }
202
203 class LWL_FM_MM<bits<4> funct> {
204   bits<5> rt;
205   bits<21> addr;
206
207   bits<32> Inst;
208
209   let Inst{31-26} = 0x18;
210   let Inst{25-21} = rt;
211   let Inst{20-16} = addr{20-16};
212   let Inst{15-12} = funct;
213   let Inst{11-0}  = addr{11-0};
214 }
215
216 class CMov_F_I_FM_MM<bits<7> func> : MMArch {
217   bits<5> rd;
218   bits<5> rs;
219   bits<3> fcc;
220
221   bits<32> Inst;
222
223   let Inst{31-26} = 0x15;
224   let Inst{25-21} = rd;
225   let Inst{20-16} = rs;
226   let Inst{15-13} = fcc;
227   let Inst{12-6}  = func;
228   let Inst{5-0}   = 0x3b;
229 }
230
231 class MTLO_FM_MM<bits<10> funct> : MMArch {
232   bits<5> rs;
233
234   bits<32> Inst;
235
236   let Inst{31-26} = 0x00;
237   let Inst{25-21} = 0x00;
238   let Inst{20-16} = rs;
239   let Inst{15-6}  = funct;
240   let Inst{5-0}   = 0x3c;
241 }
242
243 class MFLO_FM_MM<bits<10> funct> : MMArch {
244   bits<5> rd;
245
246   bits<32> Inst;
247
248   let Inst{31-26} = 0x00;
249   let Inst{25-21} = 0x00;
250   let Inst{20-16} = rd;
251   let Inst{15-6}  = funct;
252   let Inst{5-0}   = 0x3c;
253 }
254
255 class CLO_FM_MM<bits<10> funct> : MMArch {
256   bits<5> rd;
257   bits<5> rs;
258
259   bits<32> Inst;
260
261   let Inst{31-26} = 0x00;
262   let Inst{25-21} = rd;
263   let Inst{20-16} = rs;
264   let Inst{15-6}  = funct;
265   let Inst{5-0}   = 0x3c;
266 }
267
268 class SEB_FM_MM<bits<10> funct> : MMArch {
269   bits<5> rd;
270   bits<5> rt;
271
272   bits<32> Inst;
273
274   let Inst{31-26} = 0x00;
275   let Inst{25-21} = rd;
276   let Inst{20-16} = rt;
277   let Inst{15-6}  = funct;
278   let Inst{5-0}   = 0x3c;
279 }
280
281 class EXT_FM_MM<bits<6> funct> : MMArch {
282   bits<5> rt;
283   bits<5> rs;
284   bits<5> pos;
285   bits<5> size;
286
287   bits<32> Inst;
288
289   let Inst{31-26} = 0x00;
290   let Inst{25-21} = rt;
291   let Inst{20-16} = rs;
292   let Inst{15-11} = size;
293   let Inst{10-6}  = pos;
294   let Inst{5-0}   = funct;
295 }
296
297 class J_FM_MM<bits<6> op> : MMArch {
298   bits<26> target;
299
300   bits<32> Inst;
301
302   let Inst{31-26} = op;
303   let Inst{25-0}  = target;
304 }
305
306 class JR_FM_MM<bits<8> funct> : MMArch {
307   bits<5> rs;
308
309   bits<32> Inst;
310
311   let Inst{31-21} = 0x00;
312   let Inst{20-16} = rs;
313   let Inst{15-14} = 0x0;
314   let Inst{13-6}  = funct;
315   let Inst{5-0}   = 0x3c;
316 }
317
318 class JALR_FM_MM<bits<10> funct> {
319   bits<5> rs;
320   bits<5> rd;
321
322   bits<32> Inst;
323
324   let Inst{31-26} = 0x00;
325   let Inst{25-21} = rd;
326   let Inst{20-16} = rs;
327   let Inst{15-6}  = funct;
328   let Inst{5-0}   = 0x3c;
329 }
330
331 class BEQ_FM_MM<bits<6> op> : MMArch {
332   bits<5>  rs;
333   bits<5>  rt;
334   bits<16> offset;
335
336   bits<32> Inst;
337
338   let Inst{31-26} = op;
339   let Inst{25-21} = rt;
340   let Inst{20-16} = rs;
341   let Inst{15-0}  = offset;
342 }
343
344 class BGEZ_FM_MM<bits<5> funct> : MMArch {
345   bits<5>  rs;
346   bits<16> offset;
347
348   bits<32> Inst;
349
350   let Inst{31-26} = 0x10;
351   let Inst{25-21} = funct;
352   let Inst{20-16} = rs;
353   let Inst{15-0}  = offset;
354 }
355
356 class BGEZAL_FM_MM<bits<5> funct> : MMArch {
357   bits<5>  rs;
358   bits<16> offset;
359
360   bits<32> Inst;
361
362   let Inst{31-26} = 0x10;
363   let Inst{25-21} = funct;
364   let Inst{20-16} = rs;
365   let Inst{15-0}  = offset;
366 }
367
368 class SYNC_FM_MM : MMArch {
369   bits<5> stype;
370
371   bits<32> Inst;
372
373   let Inst{31-26} = 0x00;
374   let Inst{25-21} = 0x0;
375   let Inst{20-16} = stype;
376   let Inst{15-6}  = 0x1ad;
377   let Inst{5-0}   = 0x3c;
378 }
379
380 class BRK_FM_MM : MMArch {
381   bits<10> code_1;
382   bits<10> code_2;
383   bits<32> Inst;
384   let Inst{31-26} = 0x0;
385   let Inst{25-16} = code_1;
386   let Inst{15-6}  = code_2;
387   let Inst{5-0}   = 0x07;
388 }
389
390 class SYS_FM_MM : MMArch {
391   bits<10> code_;
392   bits<32> Inst;
393   let Inst{31-26} = 0x0;
394   let Inst{25-16} = code_;
395   let Inst{15-6}  = 0x22d;
396   let Inst{5-0}   = 0x3c;
397 }
398
399 class WAIT_FM_MM {
400   bits<10> code_;
401   bits<32> Inst;
402
403   let Inst{31-26} = 0x00;
404   let Inst{25-16} = code_;
405   let Inst{15-6}  = 0x24d;
406   let Inst{5-0}   = 0x3c;
407 }
408
409 class ER_FM_MM<bits<10> funct> : MMArch {
410   bits<32> Inst;
411
412   let Inst{31-26} = 0x00;
413   let Inst{25-16} = 0x00;
414   let Inst{15-6}  = funct;
415   let Inst{5-0}   = 0x3c;
416 }
417
418 class EI_FM_MM<bits<10> funct> : MMArch {
419   bits<32> Inst;
420   bits<5> rt;
421
422   let Inst{31-26} = 0x00;
423   let Inst{25-21} = 0x00;
424   let Inst{20-16} = rt;
425   let Inst{15-6}  = funct;
426   let Inst{5-0}   = 0x3c;
427 }
428
429 class TEQ_FM_MM<bits<6> funct> : MMArch {
430   bits<5> rs;
431   bits<5> rt;
432   bits<4> code_;
433
434   bits<32> Inst;
435
436   let Inst{31-26} = 0x00;
437   let Inst{25-21} = rt;
438   let Inst{20-16} = rs;
439   let Inst{15-12} = code_;
440   let Inst{11-6}  = funct;
441   let Inst{5-0}   = 0x3c;
442 }
443
444 class TEQI_FM_MM<bits<5> funct> : MMArch {
445   bits<5> rs;
446   bits<16> imm16;
447
448   bits<32> Inst;
449
450   let Inst{31-26} = 0x10;
451   let Inst{25-21} = funct;
452   let Inst{20-16} = rs;
453   let Inst{15-0}  = imm16;
454 }
455
456 class LL_FM_MM<bits<4> funct> {
457   bits<5> rt;
458   bits<21> addr;
459
460   bits<32> Inst;
461
462   let Inst{31-26} = 0x18;
463   let Inst{25-21} = rt;
464   let Inst{20-16} = addr{20-16};
465   let Inst{15-12} = funct;
466   let Inst{11-0}  = addr{11-0};
467 }
468
469 class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
470   bits<5> ft;
471   bits<5> fs;
472   bits<5> fd;
473
474   bits<32> Inst;
475
476   let Inst{31-26} = 0x15;
477   let Inst{25-21} = ft;
478   let Inst{20-16} = fs;
479   let Inst{15-11} = fd;
480   let Inst{10}    = 0;
481   let Inst{9-8}   = fmt;
482   let Inst{7-0}   = funct;
483
484   list<dag> Pattern = [];
485 }
486
487 class LWXC1_FM_MM<bits<9> funct> : MMArch {
488   bits<5> fd;
489   bits<5> base;
490   bits<5> index;
491
492   bits<32> Inst;
493
494   let Inst{31-26} = 0x15;
495   let Inst{25-21} = index;
496   let Inst{20-16} = base;
497   let Inst{15-11} = fd;
498   let Inst{10-9}  = 0x0;
499   let Inst{8-0}   = funct;
500 }
501
502 class SWXC1_FM_MM<bits<9> funct> : MMArch {
503   bits<5> fs;
504   bits<5> base;
505   bits<5> index;
506
507   bits<32> Inst;
508
509   let Inst{31-26} = 0x15;
510   let Inst{25-21} = index;
511   let Inst{20-16} = base;
512   let Inst{15-11} = fs;
513   let Inst{10-9}  = 0x0;
514   let Inst{8-0}   = funct;
515 }
516
517 class CEQS_FM_MM<bits<2> fmt> : MMArch {
518   bits<5> fs;
519   bits<5> ft;
520   bits<4> cond;
521
522   bits<32> Inst;
523
524   let Inst{31-26} = 0x15;
525   let Inst{25-21} = ft;
526   let Inst{20-16} = fs;
527   let Inst{15-13} = 0x0;  // cc
528   let Inst{12}    = 0;
529   let Inst{11-10} = fmt;
530   let Inst{9-6}   = cond;
531   let Inst{5-0}   = 0x3c;
532 }
533
534 class BC1F_FM_MM<bits<5> tf> : MMArch {
535   bits<16> offset;
536
537   bits<32> Inst;
538
539   let Inst{31-26} = 0x10;
540   let Inst{25-21} = tf;
541   let Inst{20-18} = 0x0; // cc
542   let Inst{17-16} = 0x0;
543   let Inst{15-0}  = offset;
544 }
545
546 class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
547   bits<5> fd;
548   bits<5> fs;
549
550   bits<32> Inst;
551
552   let Inst{31-26} = 0x15;
553   let Inst{25-21} = fd;
554   let Inst{20-16} = fs;
555   let Inst{15}    = 0;
556   let Inst{14}    = fmt;
557   let Inst{13-6}  = funct;
558   let Inst{5-0}   = 0x3b;
559 }
560
561 class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
562   bits<5> fd;
563   bits<5> fs;
564
565   bits<32> Inst;
566
567   let Inst{31-26} = 0x15;
568   let Inst{25-21} = fd;
569   let Inst{20-16} = fs;
570   let Inst{15}    = 0;
571   let Inst{14-13} = fmt;
572   let Inst{12-6}  = funct;
573   let Inst{5-0}   = 0x3b;
574 }
575
576 class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
577   bits<5> fd;
578   bits<5> fs;
579
580   bits<32> Inst;
581
582   let Inst{31-26} = 0x15;
583   let Inst{25-21} = fd;
584   let Inst{20-16} = fs;
585   let Inst{15-13} = 0x0; //cc
586   let Inst{12-11} = 0x0;
587   let Inst{10-9}  = fmt;
588   let Inst{8-0}   = func;
589 }
590
591 class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
592   bits<5> fd;
593   bits<5> fs;
594   bits<5> rt;
595
596   bits<32> Inst;
597
598   let Inst{31-26} = 0x15;
599   let Inst{25-21} = rt;
600   let Inst{20-16} = fs;
601   let Inst{15-11} = fd;
602   let Inst{9-8}   = fmt;
603   let Inst{7-0}   = funct;
604 }
605
606 class MFC1_FM_MM<bits<8> funct> : MMArch {
607   bits<5> rt;
608   bits<5> fs;
609
610   bits<32> Inst;
611
612   let Inst{31-26} = 0x15;
613   let Inst{25-21} = rt;
614   let Inst{20-16} = fs;
615   let Inst{15-14} = 0x0;
616   let Inst{13-6}  = funct;
617   let Inst{5-0}   = 0x3b;
618 }
619
620 class MADDS_FM_MM<bits<6> funct>: MMArch {
621   bits<5> ft;
622   bits<5> fs;
623   bits<5> fd;
624   bits<5> fr;
625
626   bits<32> Inst;
627
628   let Inst{31-26} = 0x15;
629   let Inst{25-21} = ft;
630   let Inst{20-16} = fs;
631   let Inst{15-11} = fd;
632   let Inst{10-6}  = fr;
633   let Inst{5-0}   = funct;
634 }
635
636 class COMPACT_BRANCH_FM_MM<bits<5> funct> {
637   bits<5>  rs;
638   bits<16> offset;
639
640   bits<32> Inst;
641
642   let Inst{31-26} = 0x10;
643   let Inst{25-21} = funct;
644   let Inst{20-16} = rs;
645   let Inst{15-0}  = offset;
646 }
647
648 class COP0_TLB_FM_MM<bits<10> op> : MMArch {
649   bits<32> Inst;
650
651   let Inst{31-26} = 0x0;
652   let Inst{25-16} = 0x0;
653   let Inst{15-6}  = op;
654   let Inst{5-0}   = 0x3c;
655 }