Fixed encoding of SYSCALL microMIPS instruction.
[oota-llvm.git] / lib / Target / Mips / MicroMipsInstrFormats.td
1 class MMArch {
2   string Arch = "micromips";
3   list<dag> Pattern = [];
4 }
5
6 class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
7   bits<5> rt;
8   bits<5> rs;
9   bits<5> rd;
10
11   bits<32> Inst;
12
13   let Inst{31-26} = op;
14   let Inst{25-21} = rt;
15   let Inst{20-16} = rs;
16   let Inst{15-11} = rd;
17   let Inst{10}    = 0;
18   let Inst{9-0}   = funct;
19 }
20
21 class ADDI_FM_MM<bits<6> op> : MMArch {
22   bits<5>  rs;
23   bits<5>  rt;
24   bits<16> imm16;
25
26   bits<32> Inst;
27
28   let Inst{31-26} = op;
29   let Inst{25-21} = rt;
30   let Inst{20-16} = rs;
31   let Inst{15-0}  = imm16;
32 }
33
34 class SLTI_FM_MM<bits<6> op> : MMArch {
35   bits<5> rt;
36   bits<5> rs;
37   bits<16> imm16;
38
39   bits<32> Inst;
40
41   let Inst{31-26} = op;
42   let Inst{25-21} = rt;
43   let Inst{20-16} = rs;
44   let Inst{15-0}  = imm16;
45 }
46
47 class LUI_FM_MM : MMArch {
48   bits<5> rt;
49   bits<16> imm16;
50
51   bits<32> Inst;
52
53   let Inst{31-26} = 0x10;
54   let Inst{25-21} = 0xd;
55   let Inst{20-16} = rt;
56   let Inst{15-0}  = imm16;
57 }
58
59 class MULT_FM_MM<bits<10> funct> : MMArch {
60   bits<5>  rs;
61   bits<5>  rt;
62
63   bits<32> Inst;
64
65   let Inst{31-26} = 0x00;
66   let Inst{25-21} = rt;
67   let Inst{20-16} = rs;
68   let Inst{15-6}  = funct;
69   let Inst{5-0}   = 0x3c;
70 }
71
72 class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
73   bits<5> rd;
74   bits<5> rt;
75   bits<5> shamt;
76
77   bits<32> Inst;
78
79   let Inst{31-26} = 0;
80   let Inst{25-21} = rd;
81   let Inst{20-16} = rt;
82   let Inst{15-11} = shamt;
83   let Inst{10}    = rotate;
84   let Inst{9-0}   = funct;
85 }
86
87 class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
88   bits<5> rd;
89   bits<5> rt;
90   bits<5> rs;
91
92   bits<32> Inst;
93
94   let Inst{31-26} = 0;
95   let Inst{25-21} = rt;
96   let Inst{20-16} = rs;
97   let Inst{15-11} = rd;
98   let Inst{10}    = rotate;
99   let Inst{9-0}   = funct;
100 }
101
102 class LW_FM_MM<bits<6> op> : MMArch {
103   bits<5> rt;
104   bits<21> addr;
105
106   bits<32> Inst;
107
108   let Inst{31-26} = op;
109   let Inst{25-21} = rt;
110   let Inst{20-16} = addr{20-16};
111   let Inst{15-0}  = addr{15-0};
112 }
113
114 class LWL_FM_MM<bits<4> funct> {
115   bits<5> rt;
116   bits<21> addr;
117
118   bits<32> Inst;
119
120   let Inst{31-26} = 0x18;
121   let Inst{25-21} = rt;
122   let Inst{20-16} = addr{20-16};
123   let Inst{15-12} = funct;
124   let Inst{11-0}  = addr{11-0};
125 }
126
127 class CMov_F_I_FM_MM<bits<7> func> : MMArch {
128   bits<5> rd;
129   bits<5> rs;
130   bits<3> fcc;
131
132   bits<32> Inst;
133
134   let Inst{31-26} = 0x15;
135   let Inst{25-21} = rd;
136   let Inst{20-16} = rs;
137   let Inst{15-13} = fcc;
138   let Inst{12-6}  = func;
139   let Inst{5-0}   = 0x3b;
140 }
141
142 class MTLO_FM_MM<bits<10> funct> : MMArch {
143   bits<5> rs;
144
145   bits<32> Inst;
146
147   let Inst{31-26} = 0x00;
148   let Inst{25-21} = 0x00;
149   let Inst{20-16} = rs;
150   let Inst{15-6}  = funct;
151   let Inst{5-0}   = 0x3c;
152 }
153
154 class MFLO_FM_MM<bits<10> funct> : MMArch {
155   bits<5> rd;
156
157   bits<32> Inst;
158
159   let Inst{31-26} = 0x00;
160   let Inst{25-21} = 0x00;
161   let Inst{20-16} = rd;
162   let Inst{15-6}  = funct;
163   let Inst{5-0}   = 0x3c;
164 }
165
166 class CLO_FM_MM<bits<10> funct> : MMArch {
167   bits<5> rd;
168   bits<5> rs;
169
170   bits<32> Inst;
171
172   let Inst{31-26} = 0x00;
173   let Inst{25-21} = rd;
174   let Inst{20-16} = rs;
175   let Inst{15-6}  = funct;
176   let Inst{5-0}   = 0x3c;
177 }
178
179 class SEB_FM_MM<bits<10> funct> : MMArch {
180   bits<5> rd;
181   bits<5> rt;
182
183   bits<32> Inst;
184
185   let Inst{31-26} = 0x00;
186   let Inst{25-21} = rd;
187   let Inst{20-16} = rt;
188   let Inst{15-6}  = funct;
189   let Inst{5-0}   = 0x3c;
190 }
191
192 class EXT_FM_MM<bits<6> funct> : MMArch {
193   bits<5> rt;
194   bits<5> rs;
195   bits<5> pos;
196   bits<5> size;
197
198   bits<32> Inst;
199
200   let Inst{31-26} = 0x00;
201   let Inst{25-21} = rt;
202   let Inst{20-16} = rs;
203   let Inst{15-11} = size;
204   let Inst{10-6}  = pos;
205   let Inst{5-0}   = funct;
206 }
207
208 class J_FM_MM<bits<6> op> : MMArch {
209   bits<26> target;
210
211   bits<32> Inst;
212
213   let Inst{31-26} = op;
214   let Inst{25-0}  = target;
215 }
216
217 class JR_FM_MM<bits<8> funct> : MMArch {
218   bits<5> rs;
219
220   bits<32> Inst;
221
222   let Inst{31-21} = 0x00;
223   let Inst{20-16} = rs;
224   let Inst{15-14} = 0x0;
225   let Inst{13-6}  = funct;
226   let Inst{5-0}   = 0x3c;
227 }
228
229 class JALR_FM_MM<bits<10> funct> : MMArch {
230   bits<5> rs;
231   bits<5> rd;
232
233   bits<32> Inst;
234
235   let Inst{31-26} = 0x00;
236   let Inst{25-21} = rd;
237   let Inst{20-16} = rs;
238   let Inst{15-6}  = funct;
239   let Inst{5-0}   = 0x3c;
240 }
241
242 class BEQ_FM_MM<bits<6> op> : MMArch {
243   bits<5>  rs;
244   bits<5>  rt;
245   bits<16> offset;
246
247   bits<32> Inst;
248
249   let Inst{31-26} = op;
250   let Inst{25-21} = rt;
251   let Inst{20-16} = rs;
252   let Inst{15-0}  = offset;
253 }
254
255 class BGEZ_FM_MM<bits<5> funct> : MMArch {
256   bits<5>  rs;
257   bits<16> offset;
258
259   bits<32> Inst;
260
261   let Inst{31-26} = 0x10;
262   let Inst{25-21} = funct;
263   let Inst{20-16} = rs;
264   let Inst{15-0}  = offset;
265 }
266
267 class BGEZAL_FM_MM<bits<5> funct> : MMArch {
268   bits<5>  rs;
269   bits<16> offset;
270
271   bits<32> Inst;
272
273   let Inst{31-26} = 0x10;
274   let Inst{25-21} = funct;
275   let Inst{20-16} = rs;
276   let Inst{15-0}  = offset;
277 }
278
279 class SYNC_FM_MM : MMArch {
280   bits<5> stype;
281
282   bits<32> Inst;
283
284   let Inst{31-26} = 0x00;
285   let Inst{25-21} = 0x0;
286   let Inst{20-16} = stype;
287   let Inst{15-6}  = 0x1ad;
288   let Inst{5-0}   = 0x3c;
289 }
290
291 class BRK_FM_MM : MMArch {
292   bits<10> code_1;
293   bits<10> code_2;
294   bits<32> Inst;
295   let Inst{31-26} = 0x0;
296   let Inst{25-16} = code_1;
297   let Inst{15-6}  = code_2;
298   let Inst{5-0}   = 0x07;
299 }
300
301 class SYS_FM_MM : MMArch {
302   bits<10> code_;
303   bits<32> Inst;
304   let Inst{31-26} = 0x0;
305   let Inst{25-16} = code_;
306   let Inst{15-6}  = 0x22d;
307   let Inst{5-0}   = 0x3c;
308 }
309
310 class WAIT_FM_MM : MMArch {
311   bits<32> Inst;
312
313   let Inst{31-26} = 0x00;
314   let Inst{25-16} = 0x00;
315   let Inst{15-6}  = 0x24d;
316   let Inst{5-0}   = 0x3c;
317 }
318
319 class ER_FM_MM<bits<10> funct> : MMArch {
320   bits<32> Inst;
321
322   let Inst{31-26} = 0x00;
323   let Inst{25-16} = 0x00;
324   let Inst{15-6}  = funct;
325   let Inst{5-0}   = 0x3c;
326 }
327
328 class EI_FM_MM<bits<10> funct> : MMArch {
329   bits<32> Inst;
330   bits<5> rt;
331
332   let Inst{31-26} = 0x00;
333   let Inst{25-21} = 0x00;
334   let Inst{20-16} = rt;
335   let Inst{15-6}  = funct;
336   let Inst{5-0}   = 0x3c;
337 }
338
339 class TEQ_FM_MM<bits<6> funct> : MMArch {
340   bits<5> rs;
341   bits<5> rt;
342   bits<4> code_;
343
344   bits<32> Inst;
345
346   let Inst{31-26} = 0x00;
347   let Inst{25-21} = rt;
348   let Inst{20-16} = rs;
349   let Inst{15-12} = code_;
350   let Inst{11-6}  = funct;
351   let Inst{5-0}   = 0x3c;
352 }
353
354 class TEQI_FM_MM<bits<5> funct> : MMArch {
355   bits<5> rs;
356   bits<16> imm16;
357
358   bits<32> Inst;
359
360   let Inst{31-26} = 0x10;
361   let Inst{25-21} = funct;
362   let Inst{20-16} = rs;
363   let Inst{15-0}  = imm16;
364 }
365
366 class LL_FM_MM<bits<4> funct> {
367   bits<5> rt;
368   bits<21> addr;
369
370   bits<32> Inst;
371
372   let Inst{31-26} = 0x18;
373   let Inst{25-21} = rt;
374   let Inst{20-16} = addr{20-16};
375   let Inst{15-12} = funct;
376   let Inst{11-0}  = addr{11-0};
377 }
378
379 class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
380   bits<5> ft;
381   bits<5> fs;
382   bits<5> fd;
383
384   bits<32> Inst;
385
386   let Inst{31-26} = 0x15;
387   let Inst{25-21} = ft;
388   let Inst{20-16} = fs;
389   let Inst{15-11} = fd;
390   let Inst{10}    = 0;
391   let Inst{9-8}   = fmt;
392   let Inst{7-0}   = funct;
393
394   list<dag> Pattern = [];
395 }
396
397 class LWXC1_FM_MM<bits<9> funct> : MMArch {
398   bits<5> fd;
399   bits<5> base;
400   bits<5> index;
401
402   bits<32> Inst;
403
404   let Inst{31-26} = 0x15;
405   let Inst{25-21} = index;
406   let Inst{20-16} = base;
407   let Inst{15-11} = fd;
408   let Inst{10-9}  = 0x0;
409   let Inst{8-0}   = funct;
410 }
411
412 class SWXC1_FM_MM<bits<9> funct> : MMArch {
413   bits<5> fs;
414   bits<5> base;
415   bits<5> index;
416
417   bits<32> Inst;
418
419   let Inst{31-26} = 0x15;
420   let Inst{25-21} = index;
421   let Inst{20-16} = base;
422   let Inst{15-11} = fs;
423   let Inst{10-9}  = 0x0;
424   let Inst{8-0}   = funct;
425 }
426
427 class CEQS_FM_MM<bits<2> fmt> : MMArch {
428   bits<5> fs;
429   bits<5> ft;
430   bits<4> cond;
431
432   bits<32> Inst;
433
434   let Inst{31-26} = 0x15;
435   let Inst{25-21} = ft;
436   let Inst{20-16} = fs;
437   let Inst{15-13} = 0x0;  // cc
438   let Inst{12}    = 0;
439   let Inst{11-10} = fmt;
440   let Inst{9-6}   = cond;
441   let Inst{5-0}   = 0x3c;
442 }
443
444 class BC1F_FM_MM<bits<5> tf> : MMArch {
445   bits<16> offset;
446
447   bits<32> Inst;
448
449   let Inst{31-26} = 0x10;
450   let Inst{25-21} = tf;
451   let Inst{20-18} = 0x0; // cc
452   let Inst{17-16} = 0x0;
453   let Inst{15-0}  = offset;
454 }
455
456 class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
457   bits<5> fd;
458   bits<5> fs;
459
460   bits<32> Inst;
461
462   let Inst{31-26} = 0x15;
463   let Inst{25-21} = fd;
464   let Inst{20-16} = fs;
465   let Inst{15}    = 0;
466   let Inst{14}    = fmt;
467   let Inst{13-6}  = funct;
468   let Inst{5-0}   = 0x3b;
469 }
470
471 class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
472   bits<5> fd;
473   bits<5> fs;
474
475   bits<32> Inst;
476
477   let Inst{31-26} = 0x15;
478   let Inst{25-21} = fd;
479   let Inst{20-16} = fs;
480   let Inst{15}    = 0;
481   let Inst{14-13} = fmt;
482   let Inst{12-6}  = funct;
483   let Inst{5-0}   = 0x3b;
484 }
485
486 class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
487   bits<5> fd;
488   bits<5> fs;
489
490   bits<32> Inst;
491
492   let Inst{31-26} = 0x15;
493   let Inst{25-21} = fd;
494   let Inst{20-16} = fs;
495   let Inst{15-13} = 0x0; //cc
496   let Inst{12-11} = 0x0;
497   let Inst{10-9}  = fmt;
498   let Inst{8-0}   = func;
499 }
500
501 class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
502   bits<5> fd;
503   bits<5> fs;
504   bits<5> rt;
505
506   bits<32> Inst;
507
508   let Inst{31-26} = 0x15;
509   let Inst{25-21} = rt;
510   let Inst{20-16} = fs;
511   let Inst{15-11} = fd;
512   let Inst{9-8}   = fmt;
513   let Inst{7-0}   = funct;
514 }
515
516 class MFC1_FM_MM<bits<8> funct> : MMArch {
517   bits<5> rt;
518   bits<5> fs;
519
520   bits<32> Inst;
521
522   let Inst{31-26} = 0x15;
523   let Inst{25-21} = rt;
524   let Inst{20-16} = fs;
525   let Inst{15-14} = 0x0;
526   let Inst{13-6}  = funct;
527   let Inst{5-0}   = 0x3b;
528 }
529
530 class MADDS_FM_MM<bits<6> funct>: MMArch {
531   bits<5> ft;
532   bits<5> fs;
533   bits<5> fd;
534   bits<5> fr;
535
536   bits<32> Inst;
537
538   let Inst{31-26} = 0x15;
539   let Inst{25-21} = ft;
540   let Inst{20-16} = fs;
541   let Inst{15-11} = fd;
542   let Inst{10-6}  = fr;
543   let Inst{5-0}   = funct;
544 }