]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Mips/Mips32r6InstrFormats.td
Rework printouts and logging level in ENA driver
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Mips / Mips32r6InstrFormats.td
1 //=- Mips32r6InstrFormats.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 Mips32r6 instruction formats.
11 //
12 //===----------------------------------------------------------------------===//
13
14 class R6MMR6Rel;
15
16 def MipsR62MicroMipsR6 : InstrMapping {
17   let FilterClass = "R6MMR6Rel";
18   // Instructions with the same BaseOpcode and isNVStore values form a row.
19   let RowFields = ["BaseOpcode"];
20   // Instructions with the same predicate sense form a column.
21   let ColFields = ["Arch"];
22   // The key column is the unpredicated instructions.
23   let KeyCol = ["mipsr6"];
24   // Value columns are PredSense=true and PredSense=false
25   let ValueCols = [["mipsr6"], ["micromipsr6"]];
26 }
27
28 class MipsR6Arch<string opstr> {
29   string Arch = "mipsr6";
30   string BaseOpcode = opstr;
31 }
32
33 class MipsR6Inst : MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther>,
34                    PredicateControl {
35   let DecoderNamespace = "Mips32r6_64r6";
36   let EncodingPredicates = [HasStdEnc];
37 }
38
39 //===----------------------------------------------------------------------===//
40 //
41 // Field Values
42 //
43 //===----------------------------------------------------------------------===//
44
45 class OPGROUP<bits<6> Val> {
46   bits<6> Value = Val;
47 }
48 def OPGROUP_COP0     : OPGROUP<0b010000>;
49 def OPGROUP_COP1     : OPGROUP<0b010001>;
50 def OPGROUP_COP2     : OPGROUP<0b010010>;
51 def OPGROUP_ADDI     : OPGROUP<0b001000>;
52 def OPGROUP_AUI      : OPGROUP<0b001111>;
53 def OPGROUP_BLEZ     : OPGROUP<0b000110>;
54 def OPGROUP_BGTZ     : OPGROUP<0b000111>;
55 def OPGROUP_BLEZL    : OPGROUP<0b010110>;
56 def OPGROUP_BGTZL    : OPGROUP<0b010111>;
57 def OPGROUP_DADDI    : OPGROUP<0b011000>;
58 def OPGROUP_DAUI     : OPGROUP<0b011101>;
59 def OPGROUP_PCREL    : OPGROUP<0b111011>;
60 def OPGROUP_REGIMM   : OPGROUP<0b000001>;
61 def OPGROUP_SPECIAL  : OPGROUP<0b000000>;
62 // The spec occasionally names this value LL, LLD, SC, or SCD.
63 def OPGROUP_SPECIAL3 : OPGROUP<0b011111>;
64 // The spec names this constant LWC2, LDC2, SWC2, and SDC2 in different places.
65 def OPGROUP_COP2LDST : OPGROUP<0b010010>;
66
67 class OPCODE2<bits<2> Val> {
68   bits<2> Value = Val;
69 }
70 def OPCODE2_ADDIUPC : OPCODE2<0b00>;
71 def OPCODE2_LWPC    : OPCODE2<0b01>;
72 def OPCODE2_LWUPC   : OPCODE2<0b10>;
73
74 class OPCODE3<bits<3> Val> {
75   bits<3> Value = Val;
76 }
77 def OPCODE3_LDPC : OPCODE3<0b110>;
78
79 class OPCODE5<bits<5> Val> {
80   bits<5> Value = Val;
81 }
82 def OPCODE5_ALUIPC : OPCODE5<0b11111>;
83 def OPCODE5_AUIPC  : OPCODE5<0b11110>;
84 def OPCODE5_DAHI : OPCODE5<0b00110>;
85 def OPCODE5_DATI : OPCODE5<0b11110>;
86 def OPCODE5_BC1EQZ : OPCODE5<0b01001>;
87 def OPCODE5_BC1NEZ : OPCODE5<0b01101>;
88 def OPCODE5_BC2EQZ : OPCODE5<0b01001>;
89 def OPCODE5_BC2NEZ : OPCODE5<0b01101>;
90 def OPCODE5_BGEZAL : OPCODE5<0b10001>;
91 // The next four constants are unnamed in the spec. These names are taken from
92 // the OPGROUP names they are used with.
93 def OPCODE5_LDC2   : OPCODE5<0b01110>;
94 def OPCODE5_LWC2   : OPCODE5<0b01010>;
95 def OPCODE5_SDC2   : OPCODE5<0b01111>;
96 def OPCODE5_SWC2   : OPCODE5<0b01011>;
97
98 class OPCODE6<bits<6> Val> {
99   bits<6> Value = Val;
100 }
101 def OPCODE6_ALIGN    : OPCODE6<0b100000>;
102 def OPCODE6_DALIGN   : OPCODE6<0b100100>;
103 def OPCODE6_BITSWAP  : OPCODE6<0b100000>;
104 def OPCODE6_DBITSWAP : OPCODE6<0b100100>;
105 def OPCODE6_JALR     : OPCODE6<0b001001>;
106 def OPCODE6_CACHE    : OPCODE6<0b100101>;
107 def OPCODE6_PREF     : OPCODE6<0b110101>;
108 // The next four constants are unnamed in the spec. These names are taken from
109 // the OPGROUP names they are used with.
110 def OPCODE6_LL       : OPCODE6<0b110110>;
111 def OPCODE6_LLD      : OPCODE6<0b110111>;
112 def OPCODE6_SC       : OPCODE6<0b100110>;
113 def OPCODE6_SCD      : OPCODE6<0b100111>;
114 def OPCODE6_CLO      : OPCODE6<0b010001>;
115 def OPCODE6_CLZ      : OPCODE6<0b010000>;
116 def OPCODE6_DCLO     : OPCODE6<0b010011>;
117 def OPCODE6_DCLZ     : OPCODE6<0b010010>;
118 def OPCODE6_LSA      : OPCODE6<0b000101>;
119 def OPCODE6_DLSA     : OPCODE6<0b010101>;
120 def OPCODE6_SDBBP    : OPCODE6<0b001110>;
121
122 class FIELD_FMT<bits<5> Val> {
123   bits<5> Value = Val;
124 }
125 def FIELD_FMT_S : FIELD_FMT<0b10000>;
126 def FIELD_FMT_D : FIELD_FMT<0b10001>;
127
128 class FIELD_CMP_COND<bits<5> Val> {
129   bits<5> Value = Val;
130 }
131 // Note: The CMP_COND_FMT names differ from the C_COND_FMT names.
132 def FIELD_CMP_COND_AF   : FIELD_CMP_COND<0b00000>;
133 def FIELD_CMP_COND_UN   : FIELD_CMP_COND<0b00001>;
134 def FIELD_CMP_COND_EQ   : FIELD_CMP_COND<0b00010>;
135 def FIELD_CMP_COND_UEQ  : FIELD_CMP_COND<0b00011>;
136 def FIELD_CMP_COND_LT   : FIELD_CMP_COND<0b00100>;
137 def FIELD_CMP_COND_ULT  : FIELD_CMP_COND<0b00101>;
138 def FIELD_CMP_COND_LE   : FIELD_CMP_COND<0b00110>;
139 def FIELD_CMP_COND_ULE  : FIELD_CMP_COND<0b00111>;
140 def FIELD_CMP_COND_SAF  : FIELD_CMP_COND<0b01000>;
141 def FIELD_CMP_COND_SUN  : FIELD_CMP_COND<0b01001>;
142 def FIELD_CMP_COND_SEQ  : FIELD_CMP_COND<0b01010>;
143 def FIELD_CMP_COND_SUEQ : FIELD_CMP_COND<0b01011>;
144 def FIELD_CMP_COND_SLT  : FIELD_CMP_COND<0b01100>;
145 def FIELD_CMP_COND_SULT : FIELD_CMP_COND<0b01101>;
146 def FIELD_CMP_COND_SLE  : FIELD_CMP_COND<0b01110>;
147 def FIELD_CMP_COND_SULE : FIELD_CMP_COND<0b01111>;
148
149 class FIELD_CMP_FORMAT<bits<5> Val> {
150   bits<5> Value = Val;
151 }
152 def FIELD_CMP_FORMAT_S : FIELD_CMP_FORMAT<0b10100>;
153 def FIELD_CMP_FORMAT_D : FIELD_CMP_FORMAT<0b10101>;
154
155 //===----------------------------------------------------------------------===//
156 //
157 // Disambiguators
158 //
159 //===----------------------------------------------------------------------===//
160 //
161 // Some encodings are ambiguous except by comparing field values.
162
163 class DecodeDisambiguates<string Name> {
164   string DecoderMethod = !strconcat("Decode", Name);
165 }
166
167 class DecodeDisambiguatedBy<string Name> : DecodeDisambiguates<Name> {
168   string DecoderNamespace = "Mips32r6_64r6_Ambiguous";
169 }
170
171 //===----------------------------------------------------------------------===//
172 //
173 // Encoding Formats
174 //
175 //===----------------------------------------------------------------------===//
176
177 class AUI_FM : MipsR6Inst {
178   bits<5> rs;
179   bits<5> rt;
180   bits<16> imm;
181
182   bits<32> Inst;
183
184   let Inst{31-26} = OPGROUP_AUI.Value;
185   let Inst{25-21} = rs;
186   let Inst{20-16} = rt;
187   let Inst{15-0} = imm;
188 }
189
190 class DAUI_FM : AUI_FM {
191   let Inst{31-26} = OPGROUP_DAUI.Value;
192 }
193
194 class BAL_FM : MipsR6Inst {
195   bits<16> offset;
196
197   bits<32> Inst;
198
199   let Inst{31-26} = OPGROUP_REGIMM.Value;
200   let Inst{25-21} = 0b00000;
201   let Inst{20-16} = OPCODE5_BGEZAL.Value;
202   let Inst{15-0} = offset;
203 }
204
205 class COP0_EVP_DVP_FM<bits<1> sc> : MipsR6Inst {
206   bits<5> rt;
207
208   bits<32> Inst;
209
210   let Inst{31-26} = OPGROUP_COP0.Value;
211   let Inst{25-21} = 0b01011;
212   let Inst{20-16} = rt;
213   let Inst{15-11} = 0b00000;
214   let Inst{10-6}  = 0b00000;
215   let Inst{5}     = sc;
216   let Inst{4-3}   = 0b00;
217   let Inst{2-0}   = 0b100;
218 }
219
220 class COP1_2R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
221   bits<5> fs;
222   bits<5> fd;
223
224   bits<32> Inst;
225
226   let Inst{31-26} = OPGROUP_COP1.Value;
227   let Inst{25-21} = Format.Value;
228   let Inst{20-16} = 0b00000;
229   let Inst{15-11} = fs;
230   let Inst{10-6}  = fd;
231   let Inst{5-0}   = funct;
232 }
233
234 class COP1_3R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
235   bits<5> ft;
236   bits<5> fs;
237   bits<5> fd;
238
239   bits<32> Inst;
240
241   let Inst{31-26} = OPGROUP_COP1.Value;
242   let Inst{25-21} = Format.Value;
243   let Inst{20-16} = ft;
244   let Inst{15-11} = fs;
245   let Inst{10-6} = fd;
246   let Inst{5-0} = funct;
247 }
248
249 class COP1_BCCZ_FM<OPCODE5 Operation> : MipsR6Inst {
250   bits<5> ft;
251   bits<16> offset;
252
253   bits<32> Inst;
254
255   let Inst{31-26} = OPGROUP_COP1.Value;
256   let Inst{25-21} = Operation.Value;
257   let Inst{20-16} = ft;
258   let Inst{15-0} = offset;
259 }
260
261 class COP2_BCCZ_FM<OPCODE5 Operation> : MipsR6Inst {
262   bits<5> ct;
263   bits<16> offset;
264
265   bits<32> Inst;
266
267   let Inst{31-26} = OPGROUP_COP2.Value;
268   let Inst{25-21} = Operation.Value;
269   let Inst{20-16} = ct;
270   let Inst{15-0} = offset;
271 }
272
273 class PCREL16_FM<OPCODE5 Operation> : MipsR6Inst {
274   bits<5> rs;
275   bits<16> imm;
276
277   bits<32> Inst;
278
279   let Inst{31-26} = OPGROUP_PCREL.Value;
280   let Inst{25-21} = rs;
281   let Inst{20-16} = Operation.Value;
282   let Inst{15-0} = imm;
283 }
284
285 class PCREL19_FM<OPCODE2 Operation> : MipsR6Inst {
286   bits<5> rs;
287   bits<19> imm;
288
289   bits<32> Inst;
290
291   let Inst{31-26} = OPGROUP_PCREL.Value;
292   let Inst{25-21} = rs;
293   let Inst{20-19} = Operation.Value;
294   let Inst{18-0} = imm;
295 }
296
297 class PCREL18_FM<OPCODE3 Operation> : MipsR6Inst {
298   bits<5> rs;
299   bits<18> imm;
300
301   bits<32> Inst;
302
303   let Inst{31-26} = OPGROUP_PCREL.Value;
304   let Inst{25-21} = rs;
305   let Inst{20-18} = Operation.Value;
306   let Inst{17-0} = imm;
307 }
308
309 class SPECIAL3_2R_FM<OPCODE6 Operation> : MipsR6Inst {
310   bits<5> rd;
311   bits<5> rt;
312
313   bits<32> Inst;
314
315   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
316   let Inst{25-21} = 0b00000;
317   let Inst{20-16} = rt;
318   let Inst{15-11} = rd;
319   let Inst{10-6}  = 0b00000;
320   let Inst{5-0}   = Operation.Value;
321 }
322
323 class SPECIAL3_MEM_FM<OPCODE6 Operation> : MipsR6Inst {
324   bits<21> addr;
325   bits<5> hint;
326   bits<5> base = addr{20-16};
327   bits<9> offset = addr{8-0};
328
329   bits<32> Inst;
330
331   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
332   let Inst{25-21} = base;
333   let Inst{20-16} = hint;
334   let Inst{15-7}  = offset;
335   let Inst{6}     = 0;
336   let Inst{5-0}   = Operation.Value;
337 }
338
339 class SPECIAL_2R_FM<OPCODE6 Operation> : MipsR6Inst {
340   bits<5> rd;
341   bits<5> rs;
342
343   bits<32> Inst;
344
345   let Inst{31-26} = OPGROUP_SPECIAL.Value;
346   let Inst{25-21} = rs;
347   let Inst{20-16} = 0b00000;
348   let Inst{15-11} = rd;
349   let Inst{10-6}  = 0b00001;
350   let Inst{5-0}   = Operation.Value;
351 }
352
353 class SPECIAL_3R_FM<bits<5> mulop, bits<6> funct> : MipsR6Inst {
354   bits<5> rd;
355   bits<5> rs;
356   bits<5> rt;
357
358   bits<32> Inst;
359
360   let Inst{31-26} = OPGROUP_SPECIAL.Value;
361   let Inst{25-21} = rs;
362   let Inst{20-16} = rt;
363   let Inst{15-11} = rd;
364   let Inst{10-6}  = mulop;
365   let Inst{5-0}   = funct;
366 }
367
368 class SPECIAL_SDBBP_FM : MipsR6Inst {
369   bits<20> code_;
370
371   bits<32> Inst;
372
373   let Inst{31-26} = OPGROUP_SPECIAL.Value;
374   let Inst{25-6}  = code_;
375   let Inst{5-0}   = OPCODE6_SDBBP.Value;
376 }
377
378 // This class is ambiguous with other branches:
379 //   BEQC/BNEC require that rs < rt && rs != 0
380 class CMP_BRANCH_2R_OFF16_FM<OPGROUP funct> : MipsR6Inst {
381   bits<5> rs;
382   bits<5> rt;
383   bits<16> offset;
384
385   bits<32> Inst;
386
387   let Inst{31-26} = funct.Value;
388   let Inst{25-21} = rs;
389   let Inst{20-16} = rt;
390   let Inst{15-0} = offset;
391 }
392
393 // This class is ambiguous with other branches:
394 //   BLEZC/BGEZC/BEQZALC/BNEZALC/BGTZALC require that rs == 0 && rt != 0
395 // The '1R_RT' in the name means 1 register in the rt field.
396 class CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP funct> : MipsR6Inst {
397   bits<5> rt;
398   bits<16> offset;
399
400   bits<32> Inst;
401
402   let Inst{31-26} = funct.Value;
403   let Inst{25-21} = 0b00000;
404   let Inst{20-16} = rt;
405   let Inst{15-0} = offset;
406 }
407
408 // This class is ambiguous with other branches:
409 //   BLTZC/BGTZC/BLTZALC/BGEZALC require that rs == rt && rt != 0
410 // The '1R_BOTH' in the name means 1 register in both the rs and rt fields.
411 class CMP_BRANCH_1R_BOTH_OFF16_FM<OPGROUP funct> : MipsR6Inst {
412   bits<5> rt;
413   bits<16> offset;
414
415   bits<32> Inst;
416
417   let Inst{31-26} = funct.Value;
418   let Inst{25-21} = rt;
419   let Inst{20-16} = rt;
420   let Inst{15-0} = offset;
421 }
422
423 class CMP_BRANCH_OFF21_FM<bits<6> funct> : MipsR6Inst {
424   bits<5> rs; // rs != 0
425   bits<21> offset;
426
427   bits<32> Inst;
428
429   let Inst{31-26} = funct;
430   let Inst{25-21} = rs;
431   let Inst{20-0} = offset;
432 }
433
434 class JMP_IDX_COMPACT_FM<bits<6> funct> : MipsR6Inst {
435   bits<5> rt;
436   bits<16> offset;
437
438   bits<32> Inst;
439
440   let Inst{31-26} = funct;
441   let Inst{25-21} = 0b00000;
442   let Inst{20-16} = rt;
443   let Inst{15-0} = offset;
444 }
445
446 class BRANCH_OFF26_FM<bits<6> funct> : MipsR6Inst {
447   bits<32> Inst;
448   bits<26> offset;
449
450   let Inst{31-26} = funct;
451   let Inst{25-0} = offset;
452 }
453
454 class SPECIAL3_ALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
455   bits<5> rd;
456   bits<5> rs;
457   bits<5> rt;
458   bits<2> bp;
459
460   bits<32> Inst;
461
462   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
463   let Inst{25-21} = rs;
464   let Inst{20-16} = rt;
465   let Inst{15-11} = rd;
466   let Inst{10-8}  = 0b010;
467   let Inst{7-6}   = bp;
468   let Inst{5-0}   = Operation.Value;
469 }
470
471 class SPECIAL3_DALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
472   bits<5> rd;
473   bits<5> rs;
474   bits<5> rt;
475   bits<3> bp;
476
477   bits<32> Inst;
478
479   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
480   let Inst{25-21} = rs;
481   let Inst{20-16} = rt;
482   let Inst{15-11} = rd;
483   let Inst{10-9}  = 0b01;
484   let Inst{8-6}   = bp;
485   let Inst{5-0}   = Operation.Value;
486 }
487
488 class SPECIAL3_LL_SC_FM<OPCODE6 Operation> : MipsR6Inst {
489   bits<5> rt;
490   bits<21> addr;
491   bits<5> base = addr{20-16};
492   bits<9> offset = addr{8-0};
493
494   bits<32> Inst;
495
496   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
497   let Inst{25-21} = base;
498   let Inst{20-16} = rt;
499   let Inst{15-7} = offset;
500   let Inst{5-0} = Operation.Value;
501
502   string DecoderMethod = "DecodeSpecial3LlSc";
503 }
504
505 class SPECIAL_LSA_FM<OPCODE6 Operation> : MipsR6Inst {
506   bits<5> rd;
507   bits<5> rs;
508   bits<5> rt;
509   bits<2> imm2;
510
511   bits<32> Inst;
512
513   let Inst{31-26} = OPGROUP_SPECIAL.Value;
514   let Inst{25-21} = rs;
515   let Inst{20-16} = rt;
516   let Inst{15-11} = rd;
517   let Inst{10-8}  = 0b000;
518   let Inst{7-6}   = imm2;
519   let Inst{5-0}   = Operation.Value;
520 }
521
522 class REGIMM_FM<OPCODE5 Operation> : MipsR6Inst {
523   bits<5> rs;
524   bits<16> imm;
525
526   bits<32> Inst;
527
528   let Inst{31-26} = OPGROUP_REGIMM.Value;
529   let Inst{25-21} = rs;
530   let Inst{20-16} = Operation.Value;
531   let Inst{15-0} = imm;
532 }
533
534 class COP1_CMP_CONDN_FM<FIELD_CMP_FORMAT Format,
535                         FIELD_CMP_COND Cond> : MipsR6Inst {
536   bits<5> fd;
537   bits<5> fs;
538   bits<5> ft;
539
540   bits<32> Inst;
541
542   let Inst{31-26} = OPGROUP_COP1.Value;
543   let Inst{25-21} = Format.Value;
544   let Inst{20-16} = ft;
545   let Inst{15-11} = fs;
546   let Inst{10-6}  = fd;
547   let Inst{5}     = 0;
548   let Inst{4-0}   = Cond.Value;
549 }
550
551 class JR_HB_R6_FM<OPCODE6 Operation> : MipsR6Inst {
552   bits<5> rs;
553
554   bits<32> Inst;
555
556   let Inst{31-26} = OPGROUP_SPECIAL.Value;
557   let Inst{25-21} = rs;
558   let Inst{20-16} = 0;
559   let Inst{15-11} = 0;
560   let Inst{10} = 1;
561   let Inst{9-6} = 0;
562   let Inst{5-0} = Operation.Value;
563 }
564
565 class COP2LDST_FM<OPCODE5 Operation> : MipsR6Inst {
566   bits<5> rt;
567   bits<21> addr;
568   bits<5> base = addr{20-16};
569   bits<11> offset = addr{10-0};
570
571   bits<32> Inst;
572
573   let Inst{31-26} = OPGROUP_COP2LDST.Value;
574   let Inst{25-21} = Operation.Value;
575   let Inst{20-16} = rt;
576   let Inst{15-11} = base;
577   let Inst{10-0}  = offset;
578 }