[mips][microMIPS] Implement SB, SBE, SCE, SH and SHE 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 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 SIGN_EXTEND_FM_MMR6<string instr_asm, bits<10> funct>
101     : MMR6Arch<instr_asm> {
102   bits<5> rd;
103   bits<5> rt;
104
105   bits<32> Inst;
106
107   let Inst{31-26} = 0b000000;
108   let Inst{25-21} = rd;
109   let Inst{20-16} = rt;
110   let Inst{15-6}  = funct;
111   let Inst{5-0}   = 0b111100;
112 }
113
114 class PCREL19_FM_MMR6<bits<2> funct> : MipsR6Inst {
115   bits<5> rt;
116   bits<19> imm;
117
118   bits<32> Inst;
119
120   let Inst{31-26} = 0b011110;
121   let Inst{25-21} = rt;
122   let Inst{20-19} = funct;
123   let Inst{18-0}  = imm;
124 }
125
126 class PCREL16_FM_MMR6<bits<5> funct> : MipsR6Inst {
127   bits<5> rt;
128   bits<16> imm;
129
130   bits<32> Inst;
131
132   let Inst{31-26} = 0b011110;
133   let Inst{25-21} = rt;
134   let Inst{20-16} = funct;
135   let Inst{15-0}  = imm;
136 }
137
138 class POOL32A_FM_MMR6<bits<10> funct> : MipsR6Inst {
139   bits<5> rd;
140   bits<5> rs;
141   bits<5> rt;
142
143   bits<32> Inst;
144
145   let Inst{31-26} = 0b000000;
146   let Inst{25-21} = rt;
147   let Inst{20-16} = rs;
148   let Inst{15-11} = rd;
149   let Inst{10}    = 0;
150   let Inst{9-0}   = funct;
151 }
152
153 class POOL32A_2R_FM_MMR6<bits<10> funct> : MipsR6Inst {
154   bits<5> rs;
155   bits<5> rt;
156
157   bits<32> Inst;
158
159   let Inst{31-26} = 0b000000;
160   let Inst{25-21} = rt;
161   let Inst{20-16} = rs;
162   let Inst{15-6}  = funct;
163   let Inst{5-0}   = 0b111100;
164 }
165
166 class SPECIAL_2R_FM_MMR6<bits<6> funct> : MipsR6Inst {
167   bits<5> rs;
168   bits<5> rt;
169
170   bits<32> Inst;
171
172   let Inst{31-26} = 0b000000;
173   let Inst{25-21} = rs;
174   let Inst{20-16} = 0b00000;
175   let Inst{15-11} = rt;
176   let Inst{10-6}  = 0b00001;
177   let Inst{5-0}   = funct;
178 }
179
180 class POOL32A_ALIGN_FM_MMR6<bits<6> funct> : MipsR6Inst {
181   bits<5> rd;
182   bits<5> rs;
183   bits<5> rt;
184   bits<2> bp;
185
186   bits<32> Inst;
187
188   let Inst{31-26} = 0b000000;
189   let Inst{25-21} = rs;
190   let Inst{20-16} = rt;
191   let Inst{15-11} = rd;
192   let Inst{10-9}  = bp;
193   let Inst{8-6}   = 0b000;
194   let Inst{5-0}   = funct;
195 }
196
197 class AUI_FM_MMR6 : MipsR6Inst {
198   bits<5> rs;
199   bits<5> rt;
200   bits<16> imm;
201
202   bits<32> Inst;
203
204   let Inst{31-26} = 0b000100;
205   let Inst{25-21} = rt;
206   let Inst{20-16} = rs;
207   let Inst{15-0} = imm;
208 }
209
210 class POOL32A_LSA_FM<bits<6> funct> : MipsR6Inst {
211   bits<5> rd;
212   bits<5> rs;
213   bits<5> rt;
214   bits<2> imm2;
215
216   bits<32> Inst;
217
218   let Inst{31-26} = 0b000000;
219   let Inst{25-21} = rt;
220   let Inst{20-16} = rs;
221   let Inst{15-11} = rd;
222   let Inst{10-9}  = imm2;
223   let Inst{8-6}   = 0b000;
224   let Inst{5-0}   = funct;
225 }
226
227 class SB32_SH32_STORE_FM_MMR6<bits<6> op> {
228   bits<5> rt;
229   bits<21> addr;
230   bits<5> base = addr{20-16};
231   bits<16> offset = addr{15-0};
232
233   bits<32> Inst;
234
235   let Inst{31-26} = op;
236   let Inst{25-21} = rt;
237   let Inst{20-16} = base;
238   let Inst{15-0}  = offset;
239 }
240
241 class POOL32C_STORE_EVA_FM_MMR6<bits<3> funct> {
242   bits<5> rt;
243   bits<21> addr;
244   bits<5> base = addr{20-16};
245   bits<9> offset = addr{8-0};
246
247   bits<32> Inst;
248
249   let Inst{31-26} = 0b011000;
250   let Inst{25-21} = rt;
251   let Inst{20-16} = base;
252   let Inst{15-12} = 0b1010;
253   let Inst{11-9}  = funct;
254   let Inst{8-0}   = offset;
255 }
256
257 class CMP_BRANCH_1R_RT_OFF16_FM_MMR6<bits<6> funct> : MipsR6Inst {
258   bits<5> rt;
259   bits<16> offset;
260
261   bits<32> Inst;
262
263   let Inst{31-26} = funct;
264   let Inst{25-21} = rt;
265   let Inst{20-16} = 0b00000;
266   let Inst{15-0}  = offset;
267 }
268
269 class CMP_BRANCH_1R_BOTH_OFF16_FM_MMR6<bits<6> funct> : MipsR6Inst {
270   bits<5> rt;
271   bits<16> offset;
272
273   bits<32> Inst;
274
275   let Inst{31-26} = funct;
276   let Inst{25-21} = rt;
277   let Inst{20-16} = rt;
278   let Inst{15-0}  = offset;
279 }
280
281 class ERET_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
282   bits<32> Inst;
283
284   let Inst{31-26} = 0x00;
285   let Inst{25-16} = 0x00;
286   let Inst{15-6}  = 0x3cd;
287   let Inst{5-0}   = 0x3c;
288 }
289
290 class ERETNC_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
291   bits<32> Inst;
292
293   let Inst{31-26} = 0x00;
294   let Inst{25-17} = 0x00;
295   let Inst{16-16} = 0x01;
296   let Inst{15-6}  = 0x3cd;
297   let Inst{5-0}   = 0x3c;
298 }
299
300 class BREAK_MMR6_ENC<string instr_asm> : MMR6Arch<instr_asm> {
301   bits<10> code_1;
302   bits<10> code_2;
303   bits<32> Inst;
304   let Inst{31-26} = 0x0;
305   let Inst{25-16} = code_1;
306   let Inst{15-6}  = code_2;
307   let Inst{5-0}   = 0x07;
308 }
309
310 class BARRIER_MMR6_ENC<string instr_asm, bits<5> op> : MMR6Arch<instr_asm> {
311   bits<32> Inst;
312
313   let Inst{31-26} = 0x0;
314   let Inst{25-21} = 0x0;
315   let Inst{20-16} = 0x0;
316   let Inst{15-11} = op;
317   let Inst{10-6}  = 0x0;
318   let Inst{5-0}   = 0x0;
319 }
320
321 class EIDI_MMR6_ENC<string instr_asm, bits<10> funct> : MMR6Arch<instr_asm> {
322   bits<32> Inst;
323   bits<5> rt; // Actually rs but we're sharing code with the standard encodings which call it rt
324
325   let Inst{31-26} = 0x00;
326   let Inst{25-21} = 0x00;
327   let Inst{20-16} = rt;
328   let Inst{15-6}  = funct;
329   let Inst{5-0}   = 0x3c;
330 }
331
332 class SHIFT_MMR6_ENC<string instr_asm, bits<10> funct, bit rotate> : MMR6Arch<instr_asm> {
333   bits<5> rd;
334   bits<5> rt;
335   bits<5> shamt;
336
337   bits<32> Inst;
338
339   let Inst{31-26} = 0;
340   let Inst{25-21} = rd;
341   let Inst{20-16} = rt;
342   let Inst{15-11} = shamt;
343   let Inst{10}    = rotate;
344   let Inst{9-0}   = funct;
345 }
346
347 class SW32_FM_MMR6<string instr_asm, bits<6> op> : MMR6Arch<instr_asm> {
348   bits<5> rt;
349   bits<21> addr;
350
351   bits<32> Inst;
352
353   let Inst{31-26} = op;
354   let Inst{25-21} = rt;
355   let Inst{20-16} = addr{20-16};
356   let Inst{15-0}  = addr{15-0};
357 }
358
359 class POOL32C_SWE_FM_MMR6<string instr_asm, bits<6> op, bits<4> fmt,
360     bits<3> funct> : MMR6Arch<instr_asm> {
361   bits<5> rt;
362   bits<21> addr;
363   bits<5> base = addr{20-16};
364   bits<9> offset = addr{8-0};
365
366   bits<32> Inst;
367
368   let Inst{31-26} = op;
369   let Inst{25-21} = rt;
370   let Inst{20-16} = base;
371   let Inst{15-12} = fmt;
372   let Inst{11-9} = funct;
373   let Inst{8-0}  = offset;
374 }
375
376 class POOL32F_ARITH_FM_MMR6<string instr_asm, bits<2> fmt, bits<8> funct>
377     : MMR6Arch<instr_asm>, MipsR6Inst {
378   bits<5> ft;
379   bits<5> fs;
380   bits<5> fd;
381
382   bits<32> Inst;
383
384   let Inst{31-26} = 0b010101;
385   let Inst{25-21} = ft;
386   let Inst{20-16} = fs;
387   let Inst{15-11} = fd;
388   let Inst{10}    = 0;
389   let Inst{9-8}   = fmt;
390   let Inst{7-0}   = funct;
391 }
392
393 class POOL32F_ARITHF_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
394     : MMR6Arch<instr_asm>, MipsR6Inst {
395   bits<5> ft;
396   bits<5> fs;
397   bits<5> fd;
398
399   bits<32> Inst;
400
401   let Inst{31-26} = 0b010101;
402   let Inst{25-21} = ft;
403   let Inst{20-16} = fs;
404   let Inst{15-11} = fd;
405   let Inst{10-9}  = fmt;
406   let Inst{8-0}   = funct;
407 }
408
409 class POOL32F_MOV_NEG_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
410     : MMR6Arch<instr_asm>, MipsR6Inst {
411   bits<5> ft;
412   bits<5> fs;
413
414   bits<32> Inst;
415
416   let Inst{31-26} = 0b010101;
417   let Inst{25-21} = ft;
418   let Inst{20-16} = fs;
419   let Inst{15}    = 0;
420   let Inst{14-13} = fmt;
421   let Inst{12-6}  = funct;
422   let Inst{5-0}   = 0b111011;
423 }
424
425 class POOL32F_MINMAX_FM<string instr_asm, bits<2> fmt, bits<9> funct>
426     : MMR6Arch<instr_asm>, MipsR6Inst {
427   bits<5> ft;
428   bits<5> fs;
429   bits<5> fd;
430
431   bits<32> Inst;
432
433   let Inst{31-26} = 0b010101;
434   let Inst{25-21} = ft;
435   let Inst{20-16} = fs;
436   let Inst{15-11} = fd;
437   let Inst{10-9} = fmt;
438   let Inst{8-0} = funct;
439 }
440
441 class POOL32F_CMP_FM<string instr_asm, bits<6> format, FIELD_CMP_COND Cond>
442     : MMR6Arch<instr_asm>, MipsR6Inst {
443   bits<5> ft;
444   bits<5> fs;
445   bits<5> fd;
446
447   bits<32> Inst;
448
449   let Inst{31-26} = 0b010101;
450   let Inst{25-21} = ft;
451   let Inst{20-16} = fs;
452   let Inst{15-11} = fd;
453   let Inst{10-6} = Cond.Value;
454   let Inst{5-0} = format;
455 }
456
457 class POOL32F_CVT_LW_FM<string instr_asm, bit fmt, bits<8> funct>
458     : MMR6Arch<instr_asm>, MipsR6Inst {
459   bits<5> ft;
460   bits<5> fs;
461
462   bits<32> Inst;
463   let Inst{31-26} = 0b010101;
464   let Inst{25-21} = ft;
465   let Inst{20-16} = fs;
466   let Inst{15} = 0;
467   let Inst{14} = fmt;
468   let Inst{13-6} = funct;
469   let Inst{5-0} = 0b111011;
470 }
471
472 class POOL32F_CVT_DS_FM<string instr_asm, bits<2> fmt, bits<7> funct>
473     : MMR6Arch<instr_asm>, MipsR6Inst {
474   bits<5> ft;
475   bits<5> fs;
476
477   bits<32> Inst;
478   let Inst{31-26} = 0b010101;
479   let Inst{25-21} = ft;
480   let Inst{20-16} = fs;
481   let Inst{15} = 0;
482   let Inst{14-13} = fmt;
483   let Inst{12-6} = funct;
484   let Inst{5-0} = 0b111011;
485 }
486
487 class POOL32F_ABS_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_MATH_FM_MMR6<string instr_asm, bits<1> fmt, bits<8> funct>
504     : MMR6Arch<instr_asm>, MipsR6Inst {
505   bits<5> ft;
506   bits<5> fs;
507
508   bits<32> Inst;
509
510   let Inst{31-26} = 0b010101;
511   let Inst{25-21} = ft;
512   let Inst{20-16} = fs;
513   let Inst{15}    = 0;
514   let Inst{14}    = fmt;
515   let Inst{13-6}  = funct;
516   let Inst{5-0}   = 0b111011;
517 }