blob: 9fc2f383123b7fd2362999a657ba4bc4950362a7 [file] [log] [blame]
Zoran Jovanovic87d13e52014-03-20 10:18:24 +00001//===----------------------------------------------------------------------===//
2// MicroMIPS Base Classes
3//===----------------------------------------------------------------------===//
4
5//
6// Base class for MicroMips instructions.
7// This class does not depend on the instruction size.
8//
9class 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//
30class 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
44class 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
55class 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//===----------------------------------------------------------------------===//
66// MicroMIPS 32-bit Instruction Formats
67//===----------------------------------------------------------------------===//
68
Akira Hatanakabe6a8182013-04-19 19:03:11 +000069class MMArch {
70 string Arch = "micromips";
71 list<dag> Pattern = [];
72}
73
74class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
75 bits<5> rt;
76 bits<5> rs;
77 bits<5> rd;
78
79 bits<32> Inst;
80
81 let Inst{31-26} = op;
82 let Inst{25-21} = rt;
83 let Inst{20-16} = rs;
84 let Inst{15-11} = rd;
85 let Inst{10} = 0;
86 let Inst{9-0} = funct;
87}
88
89class ADDI_FM_MM<bits<6> op> : MMArch {
90 bits<5> rs;
91 bits<5> rt;
92 bits<16> imm16;
93
94 bits<32> Inst;
95
96 let Inst{31-26} = op;
97 let Inst{25-21} = rt;
98 let Inst{20-16} = rs;
99 let Inst{15-0} = imm16;
100}
101
102class SLTI_FM_MM<bits<6> op> : MMArch {
103 bits<5> rt;
104 bits<5> rs;
105 bits<16> imm16;
106
107 bits<32> Inst;
108
109 let Inst{31-26} = op;
Zoran Jovanovicf4d4d782013-11-15 08:07:34 +0000110 let Inst{25-21} = rt;
111 let Inst{20-16} = rs;
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000112 let Inst{15-0} = imm16;
113}
114
115class LUI_FM_MM : MMArch {
116 bits<5> rt;
117 bits<16> imm16;
118
119 bits<32> Inst;
120
121 let Inst{31-26} = 0x10;
122 let Inst{25-21} = 0xd;
123 let Inst{20-16} = rt;
124 let Inst{15-0} = imm16;
125}
126
127class MULT_FM_MM<bits<10> funct> : MMArch {
128 bits<5> rs;
129 bits<5> rt;
130
131 bits<32> Inst;
132
133 let Inst{31-26} = 0x00;
134 let Inst{25-21} = rt;
135 let Inst{20-16} = rs;
136 let Inst{15-6} = funct;
137 let Inst{5-0} = 0x3c;
138}
Akira Hatanakacd9b74a2013-04-25 01:11:15 +0000139
140class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
141 bits<5> rd;
142 bits<5> rt;
143 bits<5> shamt;
144
145 bits<32> Inst;
146
147 let Inst{31-26} = 0;
148 let Inst{25-21} = rd;
149 let Inst{20-16} = rt;
150 let Inst{15-11} = shamt;
151 let Inst{10} = rotate;
152 let Inst{9-0} = funct;
153}
154
155class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
156 bits<5> rd;
157 bits<5> rt;
158 bits<5> rs;
159
160 bits<32> Inst;
161
162 let Inst{31-26} = 0;
163 let Inst{25-21} = rt;
164 let Inst{20-16} = rs;
165 let Inst{15-11} = rd;
166 let Inst{10} = rotate;
167 let Inst{9-0} = funct;
168}
Akira Hatanakaf0aa6c92013-04-25 01:21:25 +0000169
170class LW_FM_MM<bits<6> op> : MMArch {
171 bits<5> rt;
172 bits<21> addr;
173
174 bits<32> Inst;
175
176 let Inst{31-26} = op;
177 let Inst{25-21} = rt;
178 let Inst{20-16} = addr{20-16};
179 let Inst{15-0} = addr{15-0};
180}
Jack Carter97700972013-08-13 20:19:16 +0000181
182class LWL_FM_MM<bits<4> funct> {
183 bits<5> rt;
184 bits<21> addr;
185
186 bits<32> Inst;
187
188 let Inst{31-26} = 0x18;
189 let Inst{25-21} = rt;
190 let Inst{20-16} = addr{20-16};
191 let Inst{15-12} = funct;
192 let Inst{11-0} = addr{11-0};
193}
Vladimir Medice0fbb442013-09-06 12:41:17 +0000194
195class CMov_F_I_FM_MM<bits<7> func> : MMArch {
196 bits<5> rd;
197 bits<5> rs;
198 bits<3> fcc;
199
200 bits<32> Inst;
201
202 let Inst{31-26} = 0x15;
203 let Inst{25-21} = rd;
204 let Inst{20-16} = rs;
205 let Inst{15-13} = fcc;
206 let Inst{12-6} = func;
207 let Inst{5-0} = 0x3b;
208}
Vladimir Medic457ba562013-09-06 12:53:21 +0000209
210class MTLO_FM_MM<bits<10> funct> : MMArch {
211 bits<5> rs;
212
213 bits<32> Inst;
214
215 let Inst{31-26} = 0x00;
216 let Inst{25-21} = 0x00;
217 let Inst{20-16} = rs;
218 let Inst{15-6} = funct;
219 let Inst{5-0} = 0x3c;
220}
221
222class MFLO_FM_MM<bits<10> funct> : MMArch {
223 bits<5> rd;
224
225 bits<32> Inst;
226
227 let Inst{31-26} = 0x00;
228 let Inst{25-21} = 0x00;
229 let Inst{20-16} = rd;
230 let Inst{15-6} = funct;
231 let Inst{5-0} = 0x3c;
232}
Zoran Jovanovicab852782013-09-14 06:49:25 +0000233
234class CLO_FM_MM<bits<10> funct> : MMArch {
235 bits<5> rd;
236 bits<5> rs;
237
238 bits<32> Inst;
239
240 let Inst{31-26} = 0x00;
241 let Inst{25-21} = rd;
242 let Inst{20-16} = rs;
243 let Inst{15-6} = funct;
244 let Inst{5-0} = 0x3c;
245}
246
247class SEB_FM_MM<bits<10> funct> : MMArch {
248 bits<5> rd;
249 bits<5> rt;
250
251 bits<32> Inst;
252
253 let Inst{31-26} = 0x00;
254 let Inst{25-21} = rd;
255 let Inst{20-16} = rt;
256 let Inst{15-6} = funct;
257 let Inst{5-0} = 0x3c;
258}
259
260class EXT_FM_MM<bits<6> funct> : MMArch {
261 bits<5> rt;
262 bits<5> rs;
263 bits<5> pos;
264 bits<5> size;
265
266 bits<32> Inst;
267
268 let Inst{31-26} = 0x00;
269 let Inst{25-21} = rt;
270 let Inst{20-16} = rs;
271 let Inst{15-11} = size;
272 let Inst{10-6} = pos;
273 let Inst{5-0} = funct;
274}
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000275
276class J_FM_MM<bits<6> op> : MMArch {
277 bits<26> target;
278
279 bits<32> Inst;
280
281 let Inst{31-26} = op;
282 let Inst{25-0} = target;
283}
284
285class JR_FM_MM<bits<8> funct> : MMArch {
286 bits<5> rs;
287
288 bits<32> Inst;
289
290 let Inst{31-21} = 0x00;
291 let Inst{20-16} = rs;
292 let Inst{15-14} = 0x0;
293 let Inst{13-6} = funct;
294 let Inst{5-0} = 0x3c;
295}
296
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000297class JALR_FM_MM<bits<10> funct> {
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000298 bits<5> rs;
299 bits<5> rd;
300
301 bits<32> Inst;
302
303 let Inst{31-26} = 0x00;
304 let Inst{25-21} = rd;
305 let Inst{20-16} = rs;
306 let Inst{15-6} = funct;
307 let Inst{5-0} = 0x3c;
308}
Zoran Jovanovic8a80aa72013-11-04 14:53:22 +0000309
310class BEQ_FM_MM<bits<6> op> : MMArch {
311 bits<5> rs;
312 bits<5> rt;
313 bits<16> offset;
314
315 bits<32> Inst;
316
317 let Inst{31-26} = op;
318 let Inst{25-21} = rt;
319 let Inst{20-16} = rs;
320 let Inst{15-0} = offset;
321}
322
323class BGEZ_FM_MM<bits<5> funct> : MMArch {
324 bits<5> rs;
325 bits<16> offset;
326
327 bits<32> Inst;
328
329 let Inst{31-26} = 0x10;
330 let Inst{25-21} = funct;
331 let Inst{20-16} = rs;
332 let Inst{15-0} = offset;
333}
334
335class BGEZAL_FM_MM<bits<5> funct> : MMArch {
336 bits<5> rs;
337 bits<16> offset;
338
339 bits<32> Inst;
340
341 let Inst{31-26} = 0x10;
342 let Inst{25-21} = funct;
343 let Inst{20-16} = rs;
344 let Inst{15-0} = offset;
345}
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000346
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000347class SYNC_FM_MM : MMArch {
348 bits<5> stype;
349
350 bits<32> Inst;
351
352 let Inst{31-26} = 0x00;
353 let Inst{25-21} = 0x0;
354 let Inst{20-16} = stype;
355 let Inst{15-6} = 0x1ad;
356 let Inst{5-0} = 0x3c;
357}
358
359class BRK_FM_MM : MMArch {
360 bits<10> code_1;
361 bits<10> code_2;
362 bits<32> Inst;
363 let Inst{31-26} = 0x0;
364 let Inst{25-16} = code_1;
365 let Inst{15-6} = code_2;
366 let Inst{5-0} = 0x07;
367}
368
369class SYS_FM_MM : MMArch {
370 bits<10> code_;
371 bits<32> Inst;
372 let Inst{31-26} = 0x0;
373 let Inst{25-16} = code_;
Zoran Jovanovic7c6c36d2014-02-28 18:17:08 +0000374 let Inst{15-6} = 0x22d;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000375 let Inst{5-0} = 0x3c;
376}
377
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000378class WAIT_FM_MM {
379 bits<10> code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000380 bits<32> Inst;
381
382 let Inst{31-26} = 0x00;
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000383 let Inst{25-16} = code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000384 let Inst{15-6} = 0x24d;
385 let Inst{5-0} = 0x3c;
386}
387
388class ER_FM_MM<bits<10> funct> : MMArch {
389 bits<32> Inst;
390
391 let Inst{31-26} = 0x00;
392 let Inst{25-16} = 0x00;
393 let Inst{15-6} = funct;
394 let Inst{5-0} = 0x3c;
395}
396
397class EI_FM_MM<bits<10> funct> : MMArch {
398 bits<32> Inst;
399 bits<5> rt;
400
401 let Inst{31-26} = 0x00;
402 let Inst{25-21} = 0x00;
403 let Inst{20-16} = rt;
404 let Inst{15-6} = funct;
405 let Inst{5-0} = 0x3c;
406}
407
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000408class TEQ_FM_MM<bits<6> funct> : MMArch {
409 bits<5> rs;
410 bits<5> rt;
411 bits<4> code_;
412
413 bits<32> Inst;
414
415 let Inst{31-26} = 0x00;
416 let Inst{25-21} = rt;
417 let Inst{20-16} = rs;
418 let Inst{15-12} = code_;
419 let Inst{11-6} = funct;
420 let Inst{5-0} = 0x3c;
421}
Zoran Jovanovicccb70ca2013-11-13 13:15:03 +0000422
423class TEQI_FM_MM<bits<5> funct> : MMArch {
424 bits<5> rs;
425 bits<16> imm16;
426
427 bits<32> Inst;
428
429 let Inst{31-26} = 0x10;
430 let Inst{25-21} = funct;
431 let Inst{20-16} = rs;
432 let Inst{15-0} = imm16;
433}
Zoran Jovanovicff9d5f32013-12-19 16:12:56 +0000434
435class LL_FM_MM<bits<4> funct> {
436 bits<5> rt;
437 bits<21> addr;
438
439 bits<32> Inst;
440
441 let Inst{31-26} = 0x18;
442 let Inst{25-21} = rt;
443 let Inst{20-16} = addr{20-16};
444 let Inst{15-12} = funct;
445 let Inst{11-0} = addr{11-0};
446}
Zoran Jovanovicce024862013-12-20 15:44:08 +0000447
448class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
449 bits<5> ft;
450 bits<5> fs;
451 bits<5> fd;
452
453 bits<32> Inst;
454
455 let Inst{31-26} = 0x15;
456 let Inst{25-21} = ft;
457 let Inst{20-16} = fs;
458 let Inst{15-11} = fd;
459 let Inst{10} = 0;
460 let Inst{9-8} = fmt;
461 let Inst{7-0} = funct;
462
463 list<dag> Pattern = [];
464}
465
466class LWXC1_FM_MM<bits<9> funct> : MMArch {
467 bits<5> fd;
468 bits<5> base;
469 bits<5> index;
470
471 bits<32> Inst;
472
473 let Inst{31-26} = 0x15;
474 let Inst{25-21} = index;
475 let Inst{20-16} = base;
476 let Inst{15-11} = fd;
477 let Inst{10-9} = 0x0;
478 let Inst{8-0} = funct;
479}
480
481class SWXC1_FM_MM<bits<9> funct> : MMArch {
482 bits<5> fs;
483 bits<5> base;
484 bits<5> index;
485
486 bits<32> Inst;
487
488 let Inst{31-26} = 0x15;
489 let Inst{25-21} = index;
490 let Inst{20-16} = base;
491 let Inst{15-11} = fs;
492 let Inst{10-9} = 0x0;
493 let Inst{8-0} = funct;
494}
495
496class CEQS_FM_MM<bits<2> fmt> : MMArch {
497 bits<5> fs;
498 bits<5> ft;
499 bits<4> cond;
500
501 bits<32> Inst;
502
503 let Inst{31-26} = 0x15;
504 let Inst{25-21} = ft;
505 let Inst{20-16} = fs;
506 let Inst{15-13} = 0x0; // cc
507 let Inst{12} = 0;
508 let Inst{11-10} = fmt;
509 let Inst{9-6} = cond;
510 let Inst{5-0} = 0x3c;
511}
512
513class BC1F_FM_MM<bits<5> tf> : MMArch {
514 bits<16> offset;
515
516 bits<32> Inst;
517
518 let Inst{31-26} = 0x10;
519 let Inst{25-21} = tf;
520 let Inst{20-18} = 0x0; // cc
521 let Inst{17-16} = 0x0;
522 let Inst{15-0} = offset;
523}
524
525class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
526 bits<5> fd;
527 bits<5> fs;
528
529 bits<32> Inst;
530
531 let Inst{31-26} = 0x15;
532 let Inst{25-21} = fd;
533 let Inst{20-16} = fs;
534 let Inst{15} = 0;
535 let Inst{14} = fmt;
536 let Inst{13-6} = funct;
537 let Inst{5-0} = 0x3b;
538}
539
540class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
541 bits<5> fd;
542 bits<5> fs;
543
544 bits<32> Inst;
545
546 let Inst{31-26} = 0x15;
547 let Inst{25-21} = fd;
548 let Inst{20-16} = fs;
549 let Inst{15} = 0;
550 let Inst{14-13} = fmt;
551 let Inst{12-6} = funct;
552 let Inst{5-0} = 0x3b;
553}
Zoran Jovanovic8876be32013-12-25 10:09:27 +0000554
555class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
556 bits<5> fd;
557 bits<5> fs;
558
559 bits<32> Inst;
560
561 let Inst{31-26} = 0x15;
562 let Inst{25-21} = fd;
563 let Inst{20-16} = fs;
564 let Inst{15-13} = 0x0; //cc
565 let Inst{12-11} = 0x0;
566 let Inst{10-9} = fmt;
567 let Inst{8-0} = func;
568}
569
570class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
571 bits<5> fd;
572 bits<5> fs;
573 bits<5> rt;
574
575 bits<32> Inst;
576
577 let Inst{31-26} = 0x15;
578 let Inst{25-21} = rt;
579 let Inst{20-16} = fs;
580 let Inst{15-11} = fd;
581 let Inst{9-8} = fmt;
582 let Inst{7-0} = funct;
583}
584
585class MFC1_FM_MM<bits<8> funct> : MMArch {
586 bits<5> rt;
587 bits<5> fs;
588
589 bits<32> Inst;
590
591 let Inst{31-26} = 0x15;
592 let Inst{25-21} = rt;
593 let Inst{20-16} = fs;
594 let Inst{15-14} = 0x0;
595 let Inst{13-6} = funct;
596 let Inst{5-0} = 0x3b;
597}
598
599class MADDS_FM_MM<bits<6> funct>: MMArch {
600 bits<5> ft;
601 bits<5> fs;
602 bits<5> fd;
603 bits<5> fr;
604
605 bits<32> Inst;
606
607 let Inst{31-26} = 0x15;
608 let Inst{25-21} = ft;
609 let Inst{20-16} = fs;
610 let Inst{15-11} = fd;
611 let Inst{10-6} = fr;
612 let Inst{5-0} = funct;
613}