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