]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/Mips/MipsInstrFormats.td
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / Mips / MipsInstrFormats.td
1 //===-- MipsInstrFormats.td - Mips Instruction Formats -----*- tablegen -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 //===----------------------------------------------------------------------===//
10 //  Describe MIPS instructions format
11 //
12 //  CPU INSTRUCTION FORMATS
13 //
14 //  opcode  - operation code.
15 //  rs      - src reg.
16 //  rt      - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr).
17 //  rd      - dst reg, only used on 3 regs instr.
18 //  shamt   - only used on shift instructions, contains the shift amount.
19 //  funct   - combined with opcode field give us an operation code.
20 //
21 //===----------------------------------------------------------------------===//
22
23 // Format specifies the encoding used by the instruction.  This is part of the
24 // ad-hoc solution used to emit machine instruction encodings by our machine
25 // code emitter.
26 class Format<bits<4> val> {
27   bits<4> Value = val;
28 }
29
30 def Pseudo    : Format<0>;
31 def FrmR      : Format<1>;
32 def FrmI      : Format<2>;
33 def FrmJ      : Format<3>;
34 def FrmFR     : Format<4>;
35 def FrmFI     : Format<5>;
36 def FrmOther  : Format<6>; // Instruction w/ a custom format
37
38 class MMRel;
39
40 def Std2MicroMips : InstrMapping {
41   let FilterClass = "MMRel";
42   // Instructions with the same BaseOpcode and isNVStore values form a row.
43   let RowFields = ["BaseOpcode"];
44   // Instructions with the same predicate sense form a column.
45   let ColFields = ["Arch"];
46   // The key column is the unpredicated instructions.
47   let KeyCol = ["se"];
48   // Value columns are PredSense=true and PredSense=false
49   let ValueCols = [["se"], ["micromips"]];
50 }
51
52 class StdMMR6Rel;
53
54 def Std2MicroMipsR6 : InstrMapping {
55   let FilterClass = "StdMMR6Rel";
56   // Instructions with the same BaseOpcode and isNVStore values form a row.
57   let RowFields = ["BaseOpcode"];
58   // Instructions with the same predicate sense form a column.
59   let ColFields = ["Arch"];
60   // The key column is the unpredicated instructions.
61   let KeyCol = ["se"];
62   // Value columns are PredSense=true and PredSense=false
63   let ValueCols = [["se"], ["micromipsr6"]];
64 }
65
66 class StdArch {
67   string Arch = "se";
68 }
69
70 // Generic Mips Format
71 class MipsInst<dag outs, dag ins, string asmstr, list<dag> pattern,
72                InstrItinClass itin, Format f>: Instruction, PredicateControl
73 {
74   field bits<32> Inst;
75   Format Form = f;
76
77   let Namespace = "Mips";
78
79   let Size = 4;
80
81   bits<6> Opcode = 0;
82
83   // Top 6 bits are the 'opcode' field
84   let Inst{31-26} = Opcode;
85
86   let OutOperandList = outs;
87   let InOperandList  = ins;
88
89   let AsmString   = asmstr;
90   let Pattern     = pattern;
91   let Itinerary   = itin;
92
93   //
94   // Attributes specific to Mips instructions...
95   //
96   bits<4> FormBits     = Form.Value;
97   bit isCTI            = 0; // Any form of Control Transfer Instruction.
98                             // Required for MIPSR6
99   bit hasForbiddenSlot = 0; // Instruction has a forbidden slot.
100   bit IsPCRelativeLoad = 0; // Load instruction with implicit source register
101                             // ($pc) and with explicit offset and destination
102                             // register
103   bit hasFCCRegOperand = 0; // Instruction uses $fcc<X> register and is
104                             // present in MIPS-I to MIPS-III.
105
106   // TSFlags layout should be kept in sync with MCTargetDesc/MipsBaseInfo.h.
107   let TSFlags{3-0}   = FormBits;
108   let TSFlags{4}     = isCTI;
109   let TSFlags{5}     = hasForbiddenSlot;
110   let TSFlags{6}     = IsPCRelativeLoad;
111   let TSFlags{7}     = hasFCCRegOperand;
112
113   let DecoderNamespace = "Mips";
114
115   field bits<32> SoftFail = 0;
116 }
117
118 // Mips32/64 Instruction Format
119 class InstSE<dag outs, dag ins, string asmstr, list<dag> pattern,
120              InstrItinClass itin, Format f, string opstr = ""> :
121   MipsInst<outs, ins, asmstr, pattern, itin, f> {
122   let EncodingPredicates = [NotInMips16Mode];
123   string BaseOpcode = opstr;
124   string Arch;
125 }
126
127 // Mips Pseudo Instructions Format
128 class MipsPseudo<dag outs, dag ins, list<dag> pattern,
129                  InstrItinClass itin = IIPseudo> :
130   MipsInst<outs, ins, "", pattern, itin, Pseudo> {
131   let isCodeGenOnly = 1;
132   let isPseudo = 1;
133 }
134
135 // Mips32/64 Pseudo Instruction Format
136 class PseudoSE<dag outs, dag ins, list<dag> pattern,
137                InstrItinClass itin = IIPseudo> :
138   MipsPseudo<outs, ins, pattern, itin> {
139   let EncodingPredicates = [NotInMips16Mode];
140 }
141
142 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
143 // These are aliases that require C++ handling to convert to the target
144 // instruction, while InstAliases can be handled directly by tblgen.
145 class MipsAsmPseudoInst<dag outs, dag ins, string asmstr>:
146   MipsInst<outs, ins, asmstr, [], IIPseudo, Pseudo> {
147   let isPseudo = 1;
148   let hasNoSchedulingInfo = 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|gst|0000|sel|>
224 //===----------------------------------------------------------------------===//
225 class MFC3OP_FM<bits<6> op, bits<5> mfmt, bits<3> guest> : StdArch {
226   bits<5> rt;
227   bits<5> rd;
228   bits<3> sel;
229
230   bits<32> Inst;
231
232   let Inst{31-26} = op;
233   let Inst{25-21} = mfmt;
234   let Inst{20-16} = rt;
235   let Inst{15-11} = rd;
236   let Inst{10-8}  = guest;
237   let Inst{7-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   bits<3> sel;
512
513   bits<32> Inst;
514
515   let Inst{31-26} = 0x1f;
516   let Inst{25-21} = 0;
517   let Inst{20-16} = rt;
518   let Inst{15-11} = rd;
519   let Inst{10-9}  = 0b00;
520   let Inst{8-6}   = sel;
521   let Inst{5-0}   = 0x3b;
522 }
523
524 class TEQ_FM<bits<6> funct> : StdArch {
525   bits<5> rs;
526   bits<5> rt;
527   bits<10> code_;
528
529   bits<32> Inst;
530
531   let Inst{31-26} = 0;
532   let Inst{25-21} = rs;
533   let Inst{20-16} = rt;
534   let Inst{15-6}  = code_;
535   let Inst{5-0}   = funct;
536 }
537
538 class TEQI_FM<bits<5> funct> : StdArch {
539   bits<5> rs;
540   bits<16> imm16;
541
542   bits<32> Inst;
543
544   let Inst{31-26} = 1;
545   let Inst{25-21} = rs;
546   let Inst{20-16}   = funct;
547   let Inst{15-0}  = imm16;
548 }
549
550 class WAIT_FM : StdArch {
551   bits<32> Inst;
552
553   let Inst{31-26} = 0x10;
554   let Inst{25}    = 1;
555   let Inst{24-6}  = 0;
556   let Inst{5-0}   = 0x20;
557 }
558
559 class EXTS_FM<bits<6> funct> : StdArch {
560   bits<5> rt;
561   bits<5> rs;
562   bits<5> pos;
563   bits<5> lenm1;
564
565   bits<32> Inst;
566
567   let Inst{31-26} = 0x1c;
568   let Inst{25-21} = rs;
569   let Inst{20-16} = rt;
570   let Inst{15-11} = lenm1;
571   let Inst{10-6}  = pos;
572   let Inst{5-0}   = funct;
573 }
574
575 class MTMR_FM<bits<6> funct> : StdArch {
576   bits<5> rs;
577
578   bits<32> Inst;
579
580   let Inst{31-26} = 0x1c;
581   let Inst{25-21} = rs;
582   let Inst{20-6}  = 0;
583   let Inst{5-0}   = funct;
584 }
585
586 class POP_FM<bits<6> funct> : StdArch {
587   bits<5> rd;
588   bits<5> rs;
589
590   bits<32> Inst;
591
592   let Inst{31-26} = 0x1c;
593   let Inst{25-21} = rs;
594   let Inst{20-16} = 0;
595   let Inst{15-11} = rd;
596   let Inst{10-6}  = 0;
597   let Inst{5-0}   = funct;
598 }
599
600 class SEQ_FM<bits<6> funct> : StdArch {
601   bits<5> rd;
602   bits<5> rs;
603   bits<5> rt;
604
605   bits<32> Inst;
606
607   let Inst{31-26} = 0x1c;
608   let Inst{25-21} = rs;
609   let Inst{20-16} = rt;
610   let Inst{15-11} = rd;
611   let Inst{10-6}  = 0;
612   let Inst{5-0}   = funct;
613 }
614
615 class SEQI_FM<bits<6> funct> : StdArch {
616   bits<5> rs;
617   bits<5> rt;
618   bits<10> imm10;
619
620   bits<32> Inst;
621
622   let Inst{31-26} = 0x1c;
623   let Inst{25-21} = rs;
624   let Inst{20-16} = rt;
625   let Inst{15-6}  = imm10;
626   let Inst{5-0}   = funct;
627 }
628
629 class SAA_FM<bits<6> funct> : StdArch {
630   bits<5> rt;
631   bits<5> rs;
632
633   bits<32> Inst;
634
635   let Inst{31-26} = 0x1c;
636   let Inst{25-21} = rs;
637   let Inst{20-16} = rt;
638   let Inst{15-6}  = 0;
639   let Inst{5-0}   = funct;
640 }
641
642 //===----------------------------------------------------------------------===//
643 //  System calls format <op|code_|funct>
644 //===----------------------------------------------------------------------===//
645
646 class SYS_FM<bits<6> funct> : StdArch
647 {
648   bits<20> code_;
649   bits<32> Inst;
650   let Inst{31-26} = 0x0;
651   let Inst{25-6} = code_;
652   let Inst{5-0}  = funct;
653 }
654
655 //===----------------------------------------------------------------------===//
656 //  Break instruction format <op|code_1|funct>
657 //===----------------------------------------------------------------------===//
658
659 class BRK_FM<bits<6> funct> : StdArch
660 {
661   bits<10> code_1;
662   bits<10> code_2;
663   bits<32> Inst;
664   let Inst{31-26} = 0x0;
665   let Inst{25-16} = code_1;
666   let Inst{15-6}  = code_2;
667   let Inst{5-0}   = funct;
668 }
669
670 //===----------------------------------------------------------------------===//
671 //  Exception return format <Cop0|1|0|funct>
672 //===----------------------------------------------------------------------===//
673
674 class ER_FM<bits<6> funct, bit LLBit> : StdArch
675 {
676   bits<32> Inst;
677   let Inst{31-26} = 0x10;
678   let Inst{25}    = 1;
679   let Inst{24-7}  = 0;
680   let Inst{6} = LLBit;
681   let Inst{5-0}   = funct;
682 }
683
684 //===----------------------------------------------------------------------===//
685 //  Enable/disable interrupt instruction format <Cop0|MFMC0|rt|12|0|sc|0|0>
686 //===----------------------------------------------------------------------===//
687
688 class EI_FM<bits<1> sc> : StdArch
689 {
690   bits<32> Inst;
691   bits<5> rt;
692   let Inst{31-26} = 0x10;
693   let Inst{25-21} = 0xb;
694   let Inst{20-16} = rt;
695   let Inst{15-11} = 0xc;
696   let Inst{10-6}  = 0;
697   let Inst{5}     = sc;
698   let Inst{4-0}   = 0;
699 }
700
701 //===----------------------------------------------------------------------===//
702 //
703 //  FLOATING POINT INSTRUCTION FORMATS
704 //
705 //  opcode  - operation code.
706 //  fs      - src reg.
707 //  ft      - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr).
708 //  fd      - dst reg, only used on 3 regs instr.
709 //  fmt     - double or single precision.
710 //  funct   - combined with opcode field give us an operation code.
711 //
712 //===----------------------------------------------------------------------===//
713
714 //===----------------------------------------------------------------------===//
715 // Format FI instruction class in Mips : <|opcode|base|ft|immediate|>
716 //===----------------------------------------------------------------------===//
717
718 class FFI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>:
719   InstSE<outs, ins, asmstr, pattern, NoItinerary, FrmFI>
720 {
721   bits<5>  ft;
722   bits<5>  base;
723   bits<16> imm16;
724
725   let Opcode = op;
726
727   let Inst{25-21} = base;
728   let Inst{20-16} = ft;
729   let Inst{15-0}  = imm16;
730 }
731
732 class ADDS_FM<bits<6> funct, bits<5> fmt> : StdArch {
733   bits<5> fd;
734   bits<5> fs;
735   bits<5> ft;
736
737   bits<32> Inst;
738
739   let Inst{31-26} = 0x11;
740   let Inst{25-21} = fmt;
741   let Inst{20-16} = ft;
742   let Inst{15-11} = fs;
743   let Inst{10-6}  = fd;
744   let Inst{5-0}   = funct;
745 }
746
747 class ABSS_FM<bits<6> funct, bits<5> fmt> : StdArch {
748   bits<5> fd;
749   bits<5> fs;
750
751   bits<32> Inst;
752
753   let Inst{31-26} = 0x11;
754   let Inst{25-21} = fmt;
755   let Inst{20-16} = 0;
756   let Inst{15-11} = fs;
757   let Inst{10-6}  = fd;
758   let Inst{5-0}   = funct;
759 }
760
761 class MFC1_FM<bits<5> funct> : StdArch {
762   bits<5> rt;
763   bits<5> fs;
764
765   bits<32> Inst;
766
767   let Inst{31-26} = 0x11;
768   let Inst{25-21} = funct;
769   let Inst{20-16} = rt;
770   let Inst{15-11} = fs;
771   let Inst{10-0}  = 0;
772 }
773
774 class LW_FM<bits<6> op> : StdArch {
775   bits<5> rt;
776   bits<21> addr;
777
778   bits<32> Inst;
779
780   let Inst{31-26} = op;
781   let Inst{25-21} = addr{20-16};
782   let Inst{20-16} = rt;
783   let Inst{15-0}  = addr{15-0};
784 }
785
786 class MADDS_FM<bits<3> funct, bits<3> fmt> : StdArch {
787   bits<5> fd;
788   bits<5> fr;
789   bits<5> fs;
790   bits<5> ft;
791
792   bits<32> Inst;
793
794   let Inst{31-26} = 0x13;
795   let Inst{25-21} = fr;
796   let Inst{20-16} = ft;
797   let Inst{15-11} = fs;
798   let Inst{10-6}  = fd;
799   let Inst{5-3}   = funct;
800   let Inst{2-0}   = fmt;
801 }
802
803 class LWXC1_FM<bits<6> funct> : StdArch {
804   bits<5> fd;
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} = 0;
814   let Inst{10-6}  = fd;
815   let Inst{5-0}   = funct;
816 }
817
818 class SWXC1_FM<bits<6> funct> : StdArch {
819   bits<5> fs;
820   bits<5> base;
821   bits<5> index;
822
823   bits<32> Inst;
824
825   let Inst{31-26} = 0x13;
826   let Inst{25-21} = base;
827   let Inst{20-16} = index;
828   let Inst{15-11} = fs;
829   let Inst{10-6}  = 0;
830   let Inst{5-0}   = funct;
831 }
832
833 class BC1F_FM<bit nd, bit tf> : StdArch {
834   bits<3>  fcc;
835   bits<16> offset;
836
837   bits<32> Inst;
838
839   let Inst{31-26} = 0x11;
840   let Inst{25-21} = 0x8;
841   let Inst{20-18} = fcc;
842   let Inst{17} = nd;
843   let Inst{16} = tf;
844   let Inst{15-0} = offset;
845 }
846
847 class CEQS_FM<bits<5> fmt> : StdArch {
848   bits<5> fs;
849   bits<5> ft;
850   bits<3> fcc;
851   bits<4> cond;
852
853   bits<32> Inst;
854
855   let Inst{31-26} = 0x11;
856   let Inst{25-21} = fmt;
857   let Inst{20-16} = ft;
858   let Inst{15-11} = fs;
859   let Inst{10-8} = fcc;
860   let Inst{7-4} = 0x3;
861   let Inst{3-0} = cond;
862 }
863
864 class C_COND_FM<bits<5> fmt, bits<4> c> : CEQS_FM<fmt> {
865   let cond = c;
866 }
867
868 class CMov_I_F_FM<bits<6> funct, bits<5> fmt> : StdArch {
869   bits<5> fd;
870   bits<5> fs;
871   bits<5> rt;
872
873   bits<32> Inst;
874
875   let Inst{31-26} = 0x11;
876   let Inst{25-21} = fmt;
877   let Inst{20-16} = rt;
878   let Inst{15-11} = fs;
879   let Inst{10-6} = fd;
880   let Inst{5-0} = funct;
881 }
882
883 class CMov_F_I_FM<bit tf> : StdArch {
884   bits<5> rd;
885   bits<5> rs;
886   bits<3> fcc;
887
888   bits<32> Inst;
889
890   let Inst{31-26} = 0;
891   let Inst{25-21} = rs;
892   let Inst{20-18} = fcc;
893   let Inst{17} = 0;
894   let Inst{16} = tf;
895   let Inst{15-11} = rd;
896   let Inst{10-6} = 0;
897   let Inst{5-0} = 1;
898 }
899
900 class CMov_F_F_FM<bits<5> fmt, bit tf> : StdArch {
901   bits<5> fd;
902   bits<5> fs;
903   bits<3> fcc;
904
905   bits<32> Inst;
906
907   let Inst{31-26} = 0x11;
908   let Inst{25-21} = fmt;
909   let Inst{20-18} = fcc;
910   let Inst{17} = 0;
911   let Inst{16} = tf;
912   let Inst{15-11} = fs;
913   let Inst{10-6} = fd;
914   let Inst{5-0} = 0x11;
915 }
916
917 class BARRIER_FM<bits<5> op> : StdArch {
918   bits<32> Inst;
919
920   let Inst{31-26} = 0; // SPECIAL
921   let Inst{25-21} = 0;
922   let Inst{20-16} = 0; // rt = 0
923   let Inst{15-11} = 0; // rd = 0
924   let Inst{10-6} = op; // Operation
925   let Inst{5-0} = 0;   // SLL
926 }
927
928 class SDBBP_FM : StdArch {
929   bits<20> code_;
930
931   bits<32> Inst;
932
933   let Inst{31-26} = 0b011100; // SPECIAL2
934   let Inst{25-6} = code_;
935   let Inst{5-0} = 0b111111;   // SDBBP
936 }
937
938 class JR_HB_FM<bits<6> op> : StdArch{
939   bits<5> rs;
940
941   bits<32> Inst;
942
943   let Inst{31-26} = 0; // SPECIAL
944   let Inst{25-21} = rs;
945   let Inst{20-11} = 0;
946   let Inst{10} = 1;
947   let Inst{9-6} = 0;
948   let Inst{5-0} = op;
949 }
950
951 class JALR_HB_FM<bits<6> op> : StdArch {
952   bits<5> rd;
953   bits<5> rs;
954
955   bits<32> Inst;
956
957   let Inst{31-26} = 0; // SPECIAL
958   let Inst{25-21} = rs;
959   let Inst{20-16} = 0;
960   let Inst{15-11} = rd;
961   let Inst{10} = 1;
962   let Inst{9-6} = 0;
963   let Inst{5-0} = op;
964 }
965
966 class COP0_TLB_FM<bits<6> op> : StdArch {
967   bits<32> Inst;
968
969   let Inst{31-26} = 0x10; // COP0
970   let Inst{25} = 1;       // CO
971   let Inst{24-6} = 0;
972   let Inst{5-0} = op;     // Operation
973 }
974
975 class CACHEOP_FM<bits<6> op> : StdArch {
976   bits<21> addr;
977   bits<5> hint;
978   bits<5> base = addr{20-16};
979   bits<16> offset = addr{15-0};
980
981   bits<32> Inst;
982
983   let Inst{31-26} = op;
984   let Inst{25-21} = base;
985   let Inst{20-16} = hint;
986   let Inst{15-0}  = offset;
987 }
988
989 class HYPCALL_FM<bits<6> op> : StdArch {
990   bits<10> code_;
991
992   bits<32> Inst;
993
994   let Inst{31-26} = 0b010000;
995   let Inst{25}    = 1;
996   let Inst{20-11} = code_;
997   let Inst{5-0}   = op;
998 }