02ecf32d3e47025583f0ea651026dc7b08c0bf79
[oota-llvm.git] / lib / Target / Mips / MipsInstrFormats.td
1 //===-- MipsInstrFormats.td - Mips 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 //===----------------------------------------------------------------------===//
11 //  Describe MIPS instructions format
12 //
13 //  CPU INSTRUCTION FORMATS
14 //
15 //  opcode  - operation code.
16 //  rs      - src reg.
17 //  rt      - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr).
18 //  rd      - dst reg, only used on 3 regs instr.
19 //  shamt   - only used on shift instructions, contains the shift amount.
20 //  funct   - combined with opcode field give us an operation code.
21 //
22 //===----------------------------------------------------------------------===//
23
24 // Format specifies the encoding used by the instruction.  This is part of the
25 // ad-hoc solution used to emit machine instruction encodings by our machine
26 // code emitter.
27 class Format<bits<4> val> {
28   bits<4> Value = val;
29 }
30
31 def Pseudo    : Format<0>;
32 def FrmR      : Format<1>;
33 def FrmI      : Format<2>;
34 def FrmJ      : Format<3>;
35 def FrmFR     : Format<4>;
36 def FrmFI     : Format<5>;
37 def FrmOther  : Format<6>; // Instruction w/ a custom format
38
39 class MMRel;
40
41 def Std2MicroMips : InstrMapping {
42   let FilterClass = "MMRel";
43   // Instructions with the same BaseOpcode and isNVStore values form a row.
44   let RowFields = ["BaseOpcode"];
45   // Instructions with the same predicate sense form a column.
46   let ColFields = ["Arch"];
47   // The key column is the unpredicated instructions.
48   let KeyCol = ["se"];
49   // Value columns are PredSense=true and PredSense=false
50   let ValueCols = [["se"], ["micromips"]];
51 }
52
53 class StdMMR6Rel;
54
55 def Std2MicroMipsR6 : InstrMapping {
56   let FilterClass = "StdMMR6Rel";
57   // Instructions with the same BaseOpcode and isNVStore values form a row.
58   let RowFields = ["BaseOpcode"];
59   // Instructions with the same predicate sense form a column.
60   let ColFields = ["Arch"];
61   // The key column is the unpredicated instructions.
62   let KeyCol = ["se"];
63   // Value columns are PredSense=true and PredSense=false
64   let ValueCols = [["se"], ["micromipsr6"]];
65 }
66
67 class StdArch {
68   string Arch = "se";
69 }
70
71 // Generic Mips Format
72 class MipsInst<dag outs, dag ins, string asmstr, list<dag> pattern,
73                InstrItinClass itin, Format f>: Instruction
74 {
75   field bits<32> Inst;
76   Format Form = f;
77
78   let Namespace = "Mips";
79
80   let Size = 4;
81
82   bits<6> Opcode = 0;
83
84   // Top 6 bits are the 'opcode' field
85   let Inst{31-26} = Opcode;
86
87   let OutOperandList = outs;
88   let InOperandList  = ins;
89
90   let AsmString   = asmstr;
91   let Pattern     = pattern;
92   let Itinerary   = itin;
93
94   //
95   // Attributes specific to Mips instructions...
96   //
97   bits<4> FormBits = Form.Value;
98
99   // TSFlags layout should be kept in sync with MipsInstrInfo.h.
100   let TSFlags{3-0}   = FormBits;
101
102   let DecoderNamespace = "Mips";
103
104   field bits<32> SoftFail = 0;
105 }
106
107 // Mips32/64 Instruction Format
108 class InstSE<dag outs, dag ins, string asmstr, list<dag> pattern,
109              InstrItinClass itin, Format f, string opstr = ""> :
110   MipsInst<outs, ins, asmstr, pattern, itin, f>, PredicateControl {
111   let EncodingPredicates = [HasStdEnc];
112   string BaseOpcode = opstr;
113   string Arch;
114 }
115
116 // Mips Pseudo Instructions Format
117 class MipsPseudo<dag outs, dag ins, list<dag> pattern,
118                  InstrItinClass itin = IIPseudo> :
119   MipsInst<outs, ins, "", pattern, itin, Pseudo> {
120   let isCodeGenOnly = 1;
121   let isPseudo = 1;
122 }
123
124 // Mips32/64 Pseudo Instruction Format
125 class PseudoSE<dag outs, dag ins, list<dag> pattern,
126                InstrItinClass itin = IIPseudo> :
127   MipsPseudo<outs, ins, pattern, itin>, PredicateControl {
128   let EncodingPredicates = [HasStdEnc];
129 }
130
131 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
132 // These are aliases that require C++ handling to convert to the target
133 // instruction, while InstAliases can be handled directly by tblgen.
134 class MipsAsmPseudoInst<dag outs, dag ins, string asmstr>:
135   MipsInst<outs, ins, asmstr, [], IIPseudo, Pseudo> {
136   let isPseudo = 1;
137   let Pattern = [];
138 }
139 //===----------------------------------------------------------------------===//
140 // Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|>
141 //===----------------------------------------------------------------------===//
142
143 class FR<bits<6> op, bits<6> _funct, dag outs, dag ins, string asmstr,
144          list<dag> pattern, InstrItinClass itin>:
145   InstSE<outs, ins, asmstr, pattern, itin, FrmR>
146 {
147   bits<5>  rd;
148   bits<5>  rs;
149   bits<5>  rt;
150   bits<5>  shamt;
151   bits<6>  funct;
152
153   let Opcode = op;
154   let funct  = _funct;
155
156   let Inst{25-21} = rs;
157   let Inst{20-16} = rt;
158   let Inst{15-11} = rd;
159   let Inst{10-6}  = shamt;
160   let Inst{5-0}   = funct;
161 }
162
163 //===----------------------------------------------------------------------===//
164 // Format I instruction class in Mips : <|opcode|rs|rt|immediate|>
165 //===----------------------------------------------------------------------===//
166
167 class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
168          InstrItinClass itin>: InstSE<outs, ins, asmstr, pattern, itin, FrmI>
169 {
170   bits<5>  rt;
171   bits<5>  rs;
172   bits<16> imm16;
173
174   let Opcode = op;
175
176   let Inst{25-21} = rs;
177   let Inst{20-16} = rt;
178   let Inst{15-0}  = imm16;
179 }
180
181 class BranchBase<bits<6> op, dag outs, dag ins, string asmstr,
182                   list<dag> pattern, InstrItinClass itin>:
183   InstSE<outs, ins, asmstr, pattern, itin, FrmI>
184 {
185   bits<5>  rs;
186   bits<5>  rt;
187   bits<16> imm16;
188
189   let Opcode = op;
190
191   let Inst{25-21} = rs;
192   let Inst{20-16} = rt;
193   let Inst{15-0}  = imm16;
194 }
195
196 //===----------------------------------------------------------------------===//
197 // Format J instruction class in Mips : <|opcode|address|>
198 //===----------------------------------------------------------------------===//
199
200 class FJ<bits<6> op> : StdArch
201 {
202   bits<26> target;
203
204   bits<32> Inst;
205
206   let Inst{31-26} = op;
207   let Inst{25-0}  = target;
208 }
209
210 //===----------------------------------------------------------------------===//
211 // MFC instruction class in Mips : <|op|mf|rt|rd|0000000|sel|>
212 //===----------------------------------------------------------------------===//
213 class MFC3OP_FM<bits<6> op, bits<5> mfmt>
214 {
215   bits<5> rt;
216   bits<5> rd;
217   bits<3> sel;
218
219   bits<32> Inst;
220
221   let Inst{31-26} = op;
222   let Inst{25-21} = mfmt;
223   let Inst{20-16} = rt;
224   let Inst{15-11} = rd;
225   let Inst{10-3}  = 0;
226   let Inst{2-0}   = sel;
227 }
228
229 class ADD_FM<bits<6> op, bits<6> funct> : StdArch {
230   bits<5> rd;
231   bits<5> rs;
232   bits<5> rt;
233
234   bits<32> Inst;
235
236   let Inst{31-26} = op;
237   let Inst{25-21} = rs;
238   let Inst{20-16} = rt;
239   let Inst{15-11} = rd;
240   let Inst{10-6}  = 0;
241   let Inst{5-0}   = funct;
242 }
243
244 class ADDI_FM<bits<6> op> : StdArch {
245   bits<5>  rs;
246   bits<5>  rt;
247   bits<16> imm16;
248
249   bits<32> Inst;
250
251   let Inst{31-26} = op;
252   let Inst{25-21} = rs;
253   let Inst{20-16} = rt;
254   let Inst{15-0}  = imm16;
255 }
256
257 class SRA_FM<bits<6> funct, bit rotate> : StdArch {
258   bits<5> rd;
259   bits<5> rt;
260   bits<5> shamt;
261
262   bits<32> Inst;
263
264   let Inst{31-26} = 0;
265   let Inst{25-22} = 0;
266   let Inst{21}    = rotate;
267   let Inst{20-16} = rt;
268   let Inst{15-11} = rd;
269   let Inst{10-6}  = shamt;
270   let Inst{5-0}   = funct;
271 }
272
273 class SRLV_FM<bits<6> funct, bit rotate> : StdArch {
274   bits<5> rd;
275   bits<5> rt;
276   bits<5> rs;
277
278   bits<32> Inst;
279
280   let Inst{31-26} = 0;
281   let Inst{25-21} = rs;
282   let Inst{20-16} = rt;
283   let Inst{15-11} = rd;
284   let Inst{10-7}  = 0;
285   let Inst{6}     = rotate;
286   let Inst{5-0}   = funct;
287 }
288
289 class BEQ_FM<bits<6> op> : StdArch {
290   bits<5>  rs;
291   bits<5>  rt;
292   bits<16> offset;
293
294   bits<32> Inst;
295
296   let Inst{31-26} = op;
297   let Inst{25-21} = rs;
298   let Inst{20-16} = rt;
299   let Inst{15-0}  = offset;
300 }
301
302 class BGEZ_FM<bits<6> op, bits<5> funct> : StdArch {
303   bits<5>  rs;
304   bits<16> offset;
305
306   bits<32> Inst;
307
308   let Inst{31-26} = op;
309   let Inst{25-21} = rs;
310   let Inst{20-16} = funct;
311   let Inst{15-0}  = offset;
312 }
313
314 class BBIT_FM<bits<6> op> : StdArch {
315   bits<5>  rs;
316   bits<5>  p;
317   bits<16> offset;
318
319   bits<32> Inst;
320
321   let Inst{31-26} = op;
322   let Inst{25-21} = rs;
323   let Inst{20-16} = p;
324   let Inst{15-0}  = offset;
325 }
326
327 class SLTI_FM<bits<6> op> : StdArch {
328   bits<5> rt;
329   bits<5> rs;
330   bits<16> imm16;
331
332   bits<32> Inst;
333
334   let Inst{31-26} = op;
335   let Inst{25-21} = rs;
336   let Inst{20-16} = rt;
337   let Inst{15-0}  = imm16;
338 }
339
340 class MFLO_FM<bits<6> funct> : StdArch {
341   bits<5> rd;
342
343   bits<32> Inst;
344
345   let Inst{31-26} = 0;
346   let Inst{25-16} = 0;
347   let Inst{15-11} = rd;
348   let Inst{10-6}  = 0;
349   let Inst{5-0}   = funct;
350 }
351
352 class MTLO_FM<bits<6> funct> : StdArch {
353   bits<5> rs;
354
355   bits<32> Inst;
356
357   let Inst{31-26} = 0;
358   let Inst{25-21} = rs;
359   let Inst{20-6}  = 0;
360   let Inst{5-0}   = funct;
361 }
362
363 class SEB_FM<bits<5> funct, bits<6> funct2> : StdArch {
364   bits<5> rd;
365   bits<5> rt;
366
367   bits<32> Inst;
368
369   let Inst{31-26} = 0x1f;
370   let Inst{25-21} = 0;
371   let Inst{20-16} = rt;
372   let Inst{15-11} = rd;
373   let Inst{10-6}  = funct;
374   let Inst{5-0}   = funct2;
375 }
376
377 class CLO_FM<bits<6> funct> : StdArch {
378   bits<5> rd;
379   bits<5> rs;
380   bits<5> rt;
381
382   bits<32> Inst;
383
384   let Inst{31-26} = 0x1c;
385   let Inst{25-21} = rs;
386   let Inst{20-16} = rt;
387   let Inst{15-11} = rd;
388   let Inst{10-6}  = 0;
389   let Inst{5-0}   = funct;
390   let rt = rd;
391 }
392
393 class LUI_FM : StdArch {
394   bits<5> rt;
395   bits<16> imm16;
396
397   bits<32> Inst;
398
399   let Inst{31-26} = 0xf;
400   let Inst{25-21} = 0;
401   let Inst{20-16} = rt;
402   let Inst{15-0}  = imm16;
403 }
404
405 class JALR_FM {
406   bits<5> rd;
407   bits<5> rs;
408
409   bits<32> Inst;
410
411   let Inst{31-26} = 0;
412   let Inst{25-21} = rs;
413   let Inst{20-16} = 0;
414   let Inst{15-11} = rd;
415   let Inst{10-6}  = 0;
416   let Inst{5-0}   = 9;
417 }
418
419 class BGEZAL_FM<bits<5> funct> : StdArch {
420   bits<5>  rs;
421   bits<16> offset;
422
423   bits<32> Inst;
424
425   let Inst{31-26} = 1;
426   let Inst{25-21} = rs;
427   let Inst{20-16} = funct;
428   let Inst{15-0}  = offset;
429 }
430
431 class SYNC_FM : StdArch {
432   bits<5> stype;
433
434   bits<32> Inst;
435
436   let Inst{31-26} = 0;
437   let Inst{10-6}  = stype;
438   let Inst{5-0}   = 0xf;
439 }
440
441 class SYNCI_FM : StdArch {
442   // Produced by the mem_simm16 address as reg << 16 | imm (see getMemEncoding).
443   bits<21> addr;
444   bits<5> rs = addr{20-16};
445   bits<16> offset = addr{15-0};
446
447   bits<32> Inst;
448
449   let Inst{31-26} = 0b000001;
450   let Inst{25-21} = rs;
451   let Inst{20-16} = 0b11111;
452   let Inst{15-0}  = offset;
453 }
454
455 class MULT_FM<bits<6> op, bits<6> funct> : StdArch {
456   bits<5>  rs;
457   bits<5>  rt;
458
459   bits<32> Inst;
460
461   let Inst{31-26} = op;
462   let Inst{25-21} = rs;
463   let Inst{20-16} = rt;
464   let Inst{15-6}  = 0;
465   let Inst{5-0}   = funct;
466 }
467
468 class EXT_FM<bits<6> funct> : StdArch {
469   bits<5> rt;
470   bits<5> rs;
471   bits<5> pos;
472   bits<5> size;
473
474   bits<32> Inst;
475
476   let Inst{31-26} = 0x1f;
477   let Inst{25-21} = rs;
478   let Inst{20-16} = rt;
479   let Inst{15-11} = size;
480   let Inst{10-6}  = pos;
481   let Inst{5-0}   = funct;
482 }
483
484 class RDHWR_FM : StdArch {
485   bits<5> rt;
486   bits<5> rd;
487
488   bits<32> Inst;
489
490   let Inst{31-26} = 0x1f;
491   let Inst{25-21} = 0;
492   let Inst{20-16} = rt;
493   let Inst{15-11} = rd;
494   let Inst{10-6}  = 0;
495   let Inst{5-0}   = 0x3b;
496 }
497
498 class TEQ_FM<bits<6> funct> : StdArch {
499   bits<5> rs;
500   bits<5> rt;
501   bits<10> code_;
502
503   bits<32> Inst;
504
505   let Inst{31-26} = 0;
506   let Inst{25-21} = rs;
507   let Inst{20-16} = rt;
508   let Inst{15-6}  = code_;
509   let Inst{5-0}   = funct;
510 }
511
512 class TEQI_FM<bits<5> funct> : StdArch {
513   bits<5> rs;
514   bits<16> imm16;
515
516   bits<32> Inst;
517
518   let Inst{31-26} = 1;
519   let Inst{25-21} = rs;
520   let Inst{20-16}   = funct;
521   let Inst{15-0}  = imm16;
522 }
523
524 class WAIT_FM : StdArch {
525   bits<32> Inst;
526
527   let Inst{31-26} = 0x10;
528   let Inst{25}    = 1;
529   let Inst{24-6}  = 0;
530   let Inst{5-0}   = 0x20;
531 }
532
533 class EXTS_FM<bits<6> funct> : StdArch {
534   bits<5> rt;
535   bits<5> rs;
536   bits<5> pos;
537   bits<5> lenm1;
538
539   bits<32> Inst;
540
541   let Inst{31-26} = 0x1c;
542   let Inst{25-21} = rs;
543   let Inst{20-16} = rt;
544   let Inst{15-11} = lenm1;
545   let Inst{10-6}  = pos;
546   let Inst{5-0}   = funct;
547 }
548
549 class MTMR_FM<bits<6> funct> : StdArch {
550   bits<5> rs;
551
552   bits<32> Inst;
553
554   let Inst{31-26} = 0x1c;
555   let Inst{25-21} = rs;
556   let Inst{20-6}  = 0;
557   let Inst{5-0}   = funct;
558 }
559
560 class POP_FM<bits<6> funct> : StdArch {
561   bits<5> rd;
562   bits<5> rs;
563
564   bits<32> Inst;
565
566   let Inst{31-26} = 0x1c;
567   let Inst{25-21} = rs;
568   let Inst{20-16} = 0;
569   let Inst{15-11} = rd;
570   let Inst{10-6}  = 0;
571   let Inst{5-0}   = funct;
572 }
573
574 class SEQ_FM<bits<6> funct> : StdArch {
575   bits<5> rd;
576   bits<5> rs;
577   bits<5> rt;
578
579   bits<32> Inst;
580
581   let Inst{31-26} = 0x1c;
582   let Inst{25-21} = rs;
583   let Inst{20-16} = rt;
584   let Inst{15-11} = rd;
585   let Inst{10-6}  = 0;
586   let Inst{5-0}   = funct;
587 }
588
589 class SEQI_FM<bits<6> funct> : StdArch {
590   bits<5> rs;
591   bits<5> rt;
592   bits<10> imm10;
593
594   bits<32> Inst;
595
596   let Inst{31-26} = 0x1c;
597   let Inst{25-21} = rs;
598   let Inst{20-16} = rt;
599   let Inst{15-6}  = imm10;
600   let Inst{5-0}   = funct;
601 }
602
603 //===----------------------------------------------------------------------===//
604 //  System calls format <op|code_|funct>
605 //===----------------------------------------------------------------------===//
606
607 class SYS_FM<bits<6> funct> : StdArch
608 {
609   bits<20> code_;
610   bits<32> Inst;
611   let Inst{31-26} = 0x0;
612   let Inst{25-6} = code_;
613   let Inst{5-0}  = funct;
614 }
615
616 //===----------------------------------------------------------------------===//
617 //  Break instruction format <op|code_1|funct>
618 //===----------------------------------------------------------------------===//
619
620 class BRK_FM<bits<6> funct> : StdArch
621 {
622   bits<10> code_1;
623   bits<10> code_2;
624   bits<32> Inst;
625   let Inst{31-26} = 0x0;
626   let Inst{25-16} = code_1;
627   let Inst{15-6}  = code_2;
628   let Inst{5-0}   = funct;
629 }
630
631 //===----------------------------------------------------------------------===//
632 //  Exception return format <Cop0|1|0|funct>
633 //===----------------------------------------------------------------------===//
634
635 class ER_FM<bits<6> funct> : StdArch
636 {
637   bits<32> Inst;
638   let Inst{31-26} = 0x10;
639   let Inst{25}    = 1;
640   let Inst{24-6}  = 0;
641   let Inst{5-0}   = funct;
642 }
643
644
645 //===----------------------------------------------------------------------===//
646 //  Enable/disable interrupt instruction format <Cop0|MFMC0|rt|12|0|sc|0|0>
647 //===----------------------------------------------------------------------===//
648
649 class EI_FM<bits<1> sc> : StdArch
650 {
651   bits<32> Inst;
652   bits<5> rt;
653   let Inst{31-26} = 0x10;
654   let Inst{25-21} = 0xb;
655   let Inst{20-16} = rt;
656   let Inst{15-11} = 0xc;
657   let Inst{10-6}  = 0;
658   let Inst{5}     = sc;
659   let Inst{4-0}   = 0;
660 }
661
662 //===----------------------------------------------------------------------===//
663 //
664 //  FLOATING POINT INSTRUCTION FORMATS
665 //
666 //  opcode  - operation code.
667 //  fs      - src reg.
668 //  ft      - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr).
669 //  fd      - dst reg, only used on 3 regs instr.
670 //  fmt     - double or single precision.
671 //  funct   - combined with opcode field give us an operation code.
672 //
673 //===----------------------------------------------------------------------===//
674
675 //===----------------------------------------------------------------------===//
676 // Format FI instruction class in Mips : <|opcode|base|ft|immediate|>
677 //===----------------------------------------------------------------------===//
678
679 class FFI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>:
680   InstSE<outs, ins, asmstr, pattern, NoItinerary, FrmFI>
681 {
682   bits<5>  ft;
683   bits<5>  base;
684   bits<16> imm16;
685
686   let Opcode = op;
687
688   let Inst{25-21} = base;
689   let Inst{20-16} = ft;
690   let Inst{15-0}  = imm16;
691 }
692
693 class ADDS_FM<bits<6> funct, bits<5> fmt> : StdArch {
694   bits<5> fd;
695   bits<5> fs;
696   bits<5> ft;
697
698   bits<32> Inst;
699
700   let Inst{31-26} = 0x11;
701   let Inst{25-21} = fmt;
702   let Inst{20-16} = ft;
703   let Inst{15-11} = fs;
704   let Inst{10-6}  = fd;
705   let Inst{5-0}   = funct;
706 }
707
708 class ABSS_FM<bits<6> funct, bits<5> fmt> : StdArch {
709   bits<5> fd;
710   bits<5> fs;
711
712   bits<32> Inst;
713
714   let Inst{31-26} = 0x11;
715   let Inst{25-21} = fmt;
716   let Inst{20-16} = 0;
717   let Inst{15-11} = fs;
718   let Inst{10-6}  = fd;
719   let Inst{5-0}   = funct;
720 }
721
722 class MFC1_FM<bits<5> funct> : StdArch {
723   bits<5> rt;
724   bits<5> fs;
725
726   bits<32> Inst;
727
728   let Inst{31-26} = 0x11;
729   let Inst{25-21} = funct;
730   let Inst{20-16} = rt;
731   let Inst{15-11} = fs;
732   let Inst{10-0}  = 0;
733 }
734
735 class LW_FM<bits<6> op> : StdArch {
736   bits<5> rt;
737   bits<21> addr;
738
739   bits<32> Inst;
740
741   let Inst{31-26} = op;
742   let Inst{25-21} = addr{20-16};
743   let Inst{20-16} = rt;
744   let Inst{15-0}  = addr{15-0};
745 }
746
747 class MADDS_FM<bits<3> funct, bits<3> fmt> : StdArch {
748   bits<5> fd;
749   bits<5> fr;
750   bits<5> fs;
751   bits<5> ft;
752
753   bits<32> Inst;
754
755   let Inst{31-26} = 0x13;
756   let Inst{25-21} = fr;
757   let Inst{20-16} = ft;
758   let Inst{15-11} = fs;
759   let Inst{10-6}  = fd;
760   let Inst{5-3}   = funct;
761   let Inst{2-0}   = fmt;
762 }
763
764 class LWXC1_FM<bits<6> funct> : StdArch {
765   bits<5> fd;
766   bits<5> base;
767   bits<5> index;
768
769   bits<32> Inst;
770
771   let Inst{31-26} = 0x13;
772   let Inst{25-21} = base;
773   let Inst{20-16} = index;
774   let Inst{15-11} = 0;
775   let Inst{10-6}  = fd;
776   let Inst{5-0}   = funct;
777 }
778
779 class SWXC1_FM<bits<6> funct> : StdArch {
780   bits<5> fs;
781   bits<5> base;
782   bits<5> index;
783
784   bits<32> Inst;
785
786   let Inst{31-26} = 0x13;
787   let Inst{25-21} = base;
788   let Inst{20-16} = index;
789   let Inst{15-11} = fs;
790   let Inst{10-6}  = 0;
791   let Inst{5-0}   = funct;
792 }
793
794 class BC1F_FM<bit nd, bit tf> : StdArch {
795   bits<3>  fcc;
796   bits<16> offset;
797
798   bits<32> Inst;
799
800   let Inst{31-26} = 0x11;
801   let Inst{25-21} = 0x8;
802   let Inst{20-18} = fcc;
803   let Inst{17} = nd;
804   let Inst{16} = tf;
805   let Inst{15-0} = offset;
806 }
807
808 class CEQS_FM<bits<5> fmt> : StdArch {
809   bits<5> fs;
810   bits<5> ft;
811   bits<4> cond;
812
813   bits<32> Inst;
814
815   let Inst{31-26} = 0x11;
816   let Inst{25-21} = fmt;
817   let Inst{20-16} = ft;
818   let Inst{15-11} = fs;
819   let Inst{10-8} = 0; // cc
820   let Inst{7-4} = 0x3;
821   let Inst{3-0} = cond;
822 }
823
824 class C_COND_FM<bits<5> fmt, bits<4> c> : CEQS_FM<fmt> {
825   let cond = c;
826 }
827
828 class CMov_I_F_FM<bits<6> funct, bits<5> fmt> : StdArch {
829   bits<5> fd;
830   bits<5> fs;
831   bits<5> rt;
832
833   bits<32> Inst;
834
835   let Inst{31-26} = 0x11;
836   let Inst{25-21} = fmt;
837   let Inst{20-16} = rt;
838   let Inst{15-11} = fs;
839   let Inst{10-6} = fd;
840   let Inst{5-0} = funct;
841 }
842
843 class CMov_F_I_FM<bit tf> : StdArch {
844   bits<5> rd;
845   bits<5> rs;
846   bits<3> fcc;
847
848   bits<32> Inst;
849
850   let Inst{31-26} = 0;
851   let Inst{25-21} = rs;
852   let Inst{20-18} = fcc;
853   let Inst{17} = 0;
854   let Inst{16} = tf;
855   let Inst{15-11} = rd;
856   let Inst{10-6} = 0;
857   let Inst{5-0} = 1;
858 }
859
860 class CMov_F_F_FM<bits<5> fmt, bit tf> : StdArch {
861   bits<5> fd;
862   bits<5> fs;
863   bits<3> fcc;
864
865   bits<32> Inst;
866
867   let Inst{31-26} = 0x11;
868   let Inst{25-21} = fmt;
869   let Inst{20-18} = fcc;
870   let Inst{17} = 0;
871   let Inst{16} = tf;
872   let Inst{15-11} = fs;
873   let Inst{10-6} = fd;
874   let Inst{5-0} = 0x11;
875 }
876
877 class BARRIER_FM<bits<5> op> : StdArch {
878   bits<32> Inst;
879
880   let Inst{31-26} = 0; // SPECIAL
881   let Inst{25-21} = 0;
882   let Inst{20-16} = 0; // rt = 0
883   let Inst{15-11} = 0; // rd = 0
884   let Inst{10-6} = op; // Operation
885   let Inst{5-0} = 0;   // SLL
886 }
887
888 class SDBBP_FM : StdArch {
889   bits<20> code_;
890
891   bits<32> Inst;
892
893   let Inst{31-26} = 0b011100; // SPECIAL2
894   let Inst{25-6} = code_;
895   let Inst{5-0} = 0b111111;   // SDBBP
896 }
897
898 class JR_HB_FM<bits<6> op> : StdArch{
899   bits<5> rs;
900
901   bits<32> Inst;
902
903   let Inst{31-26} = 0; // SPECIAL
904   let Inst{25-21} = rs;
905   let Inst{20-11} = 0;
906   let Inst{10} = 1;
907   let Inst{9-6} = 0;
908   let Inst{5-0} = op;
909 }
910
911 class JALR_HB_FM<bits<6> op> : StdArch {
912   bits<5> rd;
913   bits<5> rs;
914
915   bits<32> Inst;
916
917   let Inst{31-26} = 0; // SPECIAL
918   let Inst{25-21} = rs;
919   let Inst{20-16} = 0;
920   let Inst{15-11} = rd;
921   let Inst{10} = 1;
922   let Inst{9-6} = 0;
923   let Inst{5-0} = op;
924 }
925
926 class COP0_TLB_FM<bits<6> op> : StdArch {
927   bits<32> Inst;
928
929   let Inst{31-26} = 0x10; // COP0
930   let Inst{25} = 1;       // CO
931   let Inst{24-6} = 0;
932   let Inst{5-0} = op;     // Operation
933 }
934
935 class CACHEOP_FM<bits<6> op> : StdArch {
936   bits<21> addr;
937   bits<5> hint;
938   bits<5> base = addr{20-16};
939   bits<16> offset = addr{15-0};
940
941   bits<32> Inst;
942
943   let Inst{31-26} = op;
944   let Inst{25-21} = base;
945   let Inst{20-16} = hint;
946   let Inst{15-0}  = offset;
947 }