[mips][mips64r6] Add LDPC instruction
[oota-llvm.git] / 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 MipsR6Inst : MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther>,
15                    PredicateControl {
16   let DecoderNamespace = "Mips32r6_64r6";
17   let EncodingPredicates = [HasStdEnc];
18 }
19
20 //===----------------------------------------------------------------------===//
21 //
22 // Field Values
23 //
24 //===----------------------------------------------------------------------===//
25
26 class OPGROUP<bits<6> Val> {
27   bits<6> Value = Val;
28 }
29 def OPGROUP_COP1     : OPGROUP<0b010001>;
30 def OPGROUP_COP2     : OPGROUP<0b010010>;
31 def OPGROUP_ADDI     : OPGROUP<0b001000>;
32 def OPGROUP_AUI      : OPGROUP<0b001111>;
33 def OPGROUP_BLEZ     : OPGROUP<0b000110>;
34 def OPGROUP_BGTZ     : OPGROUP<0b000111>;
35 def OPGROUP_BLEZL    : OPGROUP<0b010110>;
36 def OPGROUP_BGTZL    : OPGROUP<0b010111>;
37 def OPGROUP_DADDI    : OPGROUP<0b011000>;
38 def OPGROUP_DAUI     : OPGROUP<0b011101>;
39 def OPGROUP_PCREL    : OPGROUP<0b111011>;
40 def OPGROUP_REGIMM   : OPGROUP<0b000001>;
41 def OPGROUP_SPECIAL  : OPGROUP<0b000000>;
42 def OPGROUP_SPECIAL3 : OPGROUP<0b011111>;
43
44 class OPCODE2<bits<2> Val> {
45   bits<2> Value = Val;
46 }
47 def OPCODE2_ADDIUPC : OPCODE2<0b00>;
48 def OPCODE2_LWPC    : OPCODE2<0b01>;
49 def OPCODE2_LWUPC   : OPCODE2<0b10>;
50
51 class OPCODE3<bits<3> Val> {
52   bits<3> Value = Val;
53 }
54 def OPCODE3_LDPC : OPCODE3<0b110>;
55
56 class OPCODE5<bits<5> Val> {
57   bits<5> Value = Val;
58 }
59 def OPCODE5_ALUIPC : OPCODE5<0b11111>;
60 def OPCODE5_AUIPC  : OPCODE5<0b11110>;
61 def OPCODE5_DAHI : OPCODE5<0b00110>;
62 def OPCODE5_DATI : OPCODE5<0b11110>;
63 def OPCODE5_BC1EQZ : OPCODE5<0b01001>;
64 def OPCODE5_BC1NEZ : OPCODE5<0b01101>;
65 def OPCODE5_BC2EQZ : OPCODE5<0b01001>;
66 def OPCODE5_BC2NEZ : OPCODE5<0b01101>;
67
68 class OPCODE6<bits<6> Val> {
69   bits<6> Value = Val;
70 }
71 def OPCODE6_ALIGN    : OPCODE6<0b100000>;
72 def OPCODE6_DALIGN   : OPCODE6<0b100100>;
73 def OPCODE6_BITSWAP  : OPCODE6<0b100000>;
74 def OPCODE6_DBITSWAP : OPCODE6<0b100100>;
75
76 class FIELD_FMT<bits<5> Val> {
77   bits<5> Value = Val;
78 }
79 def FIELD_FMT_S : FIELD_FMT<0b10000>;
80 def FIELD_FMT_D : FIELD_FMT<0b10001>;
81
82 class FIELD_CMP_COND<bits<5> Val> {
83   bits<5> Value = Val;
84 }
85 def FIELD_CMP_COND_F    : FIELD_CMP_COND<0b00000>;
86 def FIELD_CMP_COND_UN   : FIELD_CMP_COND<0b00001>;
87 def FIELD_CMP_COND_EQ   : FIELD_CMP_COND<0b00010>;
88 def FIELD_CMP_COND_UEQ  : FIELD_CMP_COND<0b00011>;
89 def FIELD_CMP_COND_OLT  : FIELD_CMP_COND<0b00100>;
90 def FIELD_CMP_COND_ULT  : FIELD_CMP_COND<0b00101>;
91 def FIELD_CMP_COND_OLE  : FIELD_CMP_COND<0b00110>;
92 def FIELD_CMP_COND_ULE  : FIELD_CMP_COND<0b00111>;
93 def FIELD_CMP_COND_SF   : FIELD_CMP_COND<0b01000>;
94 def FIELD_CMP_COND_NGLE : FIELD_CMP_COND<0b01001>;
95 def FIELD_CMP_COND_SEQ  : FIELD_CMP_COND<0b01010>;
96 def FIELD_CMP_COND_NGL  : FIELD_CMP_COND<0b01011>;
97 def FIELD_CMP_COND_LT   : FIELD_CMP_COND<0b01100>;
98 def FIELD_CMP_COND_NGE  : FIELD_CMP_COND<0b01101>;
99 def FIELD_CMP_COND_LE   : FIELD_CMP_COND<0b01110>;
100 def FIELD_CMP_COND_NGT  : FIELD_CMP_COND<0b01111>;
101
102 class FIELD_CMP_FORMAT<bits<5> Val> {
103   bits<5> Value = Val;
104 }
105 def FIELD_CMP_FORMAT_S : FIELD_CMP_FORMAT<0b10100>;
106 def FIELD_CMP_FORMAT_D : FIELD_CMP_FORMAT<0b10101>;
107
108 //===----------------------------------------------------------------------===//
109 //
110 // Disambiguators
111 //
112 //===----------------------------------------------------------------------===//
113 //
114 // Some encodings are ambiguous except by comparing field values.
115
116 class DecodeDisambiguates<string Name> {
117   string DecoderMethod = !strconcat("Decode", Name);
118 }
119
120 class DecodeDisambiguatedBy<string Name> : DecodeDisambiguates<Name> {
121   string DecoderNamespace = "Mips32r6_64r6_Ambiguous";
122 }
123
124 //===----------------------------------------------------------------------===//
125 //
126 // Encoding Formats
127 //
128 //===----------------------------------------------------------------------===//
129
130 class AUI_FM : MipsR6Inst {
131   bits<5> rs;
132   bits<5> rt;
133   bits<16> imm;
134
135   bits<32> Inst;
136
137   let Inst{31-26} = OPGROUP_AUI.Value;
138   let Inst{25-21} = rs;
139   let Inst{20-16} = rt;
140   let Inst{15-0} = imm;
141 }
142
143 class DAUI_FM : AUI_FM {
144   let Inst{31-26} = OPGROUP_DAUI.Value;
145 }
146
147 class COP1_2R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
148   bits<5> fs;
149   bits<5> fd;
150
151   bits<32> Inst;
152
153   let Inst{31-26} = OPGROUP_COP1.Value;
154   let Inst{25-21} = Format.Value;
155   let Inst{20-16} = 0b00000;
156   let Inst{15-11} = fs;
157   let Inst{10-6}  = fd;
158   let Inst{5-0}   = funct;
159 }
160
161 class COP1_3R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
162   bits<5> ft;
163   bits<5> fs;
164   bits<5> fd;
165
166   bits<32> Inst;
167
168   let Inst{31-26} = OPGROUP_COP1.Value;
169   let Inst{25-21} = Format.Value;
170   let Inst{20-16} = ft;
171   let Inst{15-11} = fs;
172   let Inst{10-6} = fd;
173   let Inst{5-0} = funct;
174 }
175
176 class COP1_BCCZ_FM<OPCODE5 Operation> : MipsR6Inst {
177   bits<5> ft;
178   bits<16> offset;
179
180   bits<32> Inst;
181
182   let Inst{31-26} = OPGROUP_COP1.Value;
183   let Inst{25-21} = Operation.Value;
184   let Inst{20-16} = ft;
185   let Inst{15-0} = offset;
186 }
187
188 class COP2_BCCZ_FM<OPCODE5 Operation> : MipsR6Inst {
189   bits<5> ct;
190   bits<16> offset;
191
192   bits<32> Inst;
193
194   let Inst{31-26} = OPGROUP_COP2.Value;
195   let Inst{25-21} = Operation.Value;
196   let Inst{20-16} = ct;
197   let Inst{15-0} = offset;
198 }
199
200 class PCREL16_FM<OPCODE5 Operation> : MipsR6Inst {
201   bits<5> rs;
202   bits<16> imm;
203
204   bits<32> Inst;
205
206   let Inst{31-26} = OPGROUP_PCREL.Value;
207   let Inst{25-21} = rs;
208   let Inst{20-16} = Operation.Value;
209   let Inst{15-0} = imm;
210 }
211
212 class PCREL19_FM<OPCODE2 Operation> : MipsR6Inst {
213   bits<5> rs;
214   bits<19> imm;
215
216   bits<32> Inst;
217
218   let Inst{31-26} = OPGROUP_PCREL.Value;
219   let Inst{25-21} = rs;
220   let Inst{20-19} = Operation.Value;
221   let Inst{18-0} = imm;
222 }
223
224 class PCREL18_FM<OPCODE3 Operation> : MipsR6Inst {
225   bits<5> rs;
226   bits<18> imm;
227
228   bits<32> Inst;
229
230   let Inst{31-26} = OPGROUP_PCREL.Value;
231   let Inst{25-21} = rs;
232   let Inst{20-18} = Operation.Value;
233   let Inst{17-0} = imm;
234 }
235
236 class SPECIAL3_2R_FM<OPCODE6 Operation> : MipsR6Inst {
237   bits<5> rd;
238   bits<5> rt;
239
240   bits<32> Inst;
241
242   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
243   let Inst{25-21} = 0b00000;
244   let Inst{20-16} = rt;
245   let Inst{15-11} = rd;
246   let Inst{10-6}  = 0b00000;
247   let Inst{5-0}   = Operation.Value;
248 }
249
250 class SPECIAL_3R_FM<bits<5> mulop, bits<6> funct> : MipsR6Inst {
251   bits<5> rd;
252   bits<5> rs;
253   bits<5> rt;
254
255   bits<32> Inst;
256
257   let Inst{31-26} = OPGROUP_SPECIAL.Value;
258   let Inst{25-21} = rs;
259   let Inst{20-16} = rt;
260   let Inst{15-11} = rd;
261   let Inst{10-6}  = mulop;
262   let Inst{5-0}   = funct;
263 }
264
265 // This class is ambiguous with other branches:
266 //   BEQC/BNEC require that rs > rt
267 class CMP_BRANCH_2R_OFF16_FM<OPGROUP funct> : MipsR6Inst {
268   bits<5> rs;
269   bits<5> rt;
270   bits<16> offset;
271
272   bits<32> Inst;
273
274   let Inst{31-26} = funct.Value;
275   let Inst{25-21} = rs;
276   let Inst{20-16} = rt;
277   let Inst{15-0} = offset;
278 }
279
280 // This class is ambiguous with other branches:
281 //   BLEZC/BGEZC/BEQZALC/BNEZALC/BGTZALC require that rs == 0 && rt != 0
282 // The '1R_RT' in the name means 1 register in the rt field.
283 class CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP funct> : MipsR6Inst {
284   bits<5> rt;
285   bits<16> offset;
286
287   bits<32> Inst;
288
289   let Inst{31-26} = funct.Value;
290   let Inst{25-21} = 0b00000;
291   let Inst{20-16} = rt;
292   let Inst{15-0} = offset;
293 }
294
295 // This class is ambiguous with other branches:
296 //   BLTZC/BGTZC/BLTZALC/BGEZALC require that rs == rt && rt != 0
297 // The '1R_BOTH' in the name means 1 register in both the rs and rt fields.
298 class CMP_BRANCH_1R_BOTH_OFF16_FM<OPGROUP funct> : MipsR6Inst {
299   bits<5> rt;
300   bits<16> offset;
301
302   bits<32> Inst;
303
304   let Inst{31-26} = funct.Value;
305   let Inst{25-21} = rt;
306   let Inst{20-16} = rt;
307   let Inst{15-0} = offset;
308 }
309
310 class CMP_BRANCH_OFF21_FM<bits<6> funct> : MipsR6Inst {
311   bits<5> rs; // rs != 0
312   bits<21> offset;
313
314   bits<32> Inst;
315
316   let Inst{31-26} = funct;
317   let Inst{25-21} = rs;
318   let Inst{20-0} = offset;
319 }
320
321 class JMP_IDX_COMPACT_FM<bits<6> funct> : MipsR6Inst {
322   bits<5> rt;
323   bits<16> offset;
324
325   bits<32> Inst;
326
327   let Inst{31-26} = funct;
328   let Inst{25-21} = 0b000000;
329   let Inst{20-16} = rt;
330   let Inst{15-0} = offset;
331 }
332
333 class BRANCH_OFF26_FM<bits<6> funct> : MipsR6Inst {
334   bits<32> Inst;
335   bits<26> offset;
336
337   let Inst{31-26} = funct;
338   let Inst{25-0} = offset;
339 }
340
341 class SPECIAL3_ALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
342   bits<5> rd;
343   bits<5> rs;
344   bits<5> rt;
345   bits<2> bp;
346
347   bits<32> Inst;
348
349   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
350   let Inst{25-21} = rs;
351   let Inst{20-16} = rt;
352   let Inst{15-11} = rd;
353   let Inst{10-8}  = 0b010;
354   let Inst{7-6}   = bp;
355   let Inst{5-0}   = Operation.Value;
356 }
357
358 class SPECIAL3_DALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
359   bits<5> rd;
360   bits<5> rs;
361   bits<5> rt;
362   bits<3> bp;
363
364   bits<32> Inst;
365
366   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
367   let Inst{25-21} = rs;
368   let Inst{20-16} = rt;
369   let Inst{15-11} = rd;
370   let Inst{10-9}  = 0b01;
371   let Inst{8-6}   = bp;
372   let Inst{5-0}   = Operation.Value;
373 }
374
375 class REGIMM_FM<OPCODE5 Operation> : MipsR6Inst {
376   bits<5> rs;
377   bits<16> imm;
378
379   bits<32> Inst;
380
381   let Inst{31-26} = OPGROUP_REGIMM.Value;
382   let Inst{25-21} = rs;
383   let Inst{20-16} = Operation.Value;
384   let Inst{15-0} = imm;
385 }
386
387 class COP1_CMP_CONDN_FM<FIELD_CMP_FORMAT Format,
388                         FIELD_CMP_COND Cond> : MipsR6Inst {
389   bits<5> fd;
390   bits<5> fs;
391   bits<5> ft;
392
393   bits<32> Inst;
394
395   let Inst{31-26} = OPGROUP_COP1.Value;
396   let Inst{25-21} = Format.Value;
397   let Inst{20-16} = ft;
398   let Inst{15-11} = fs;
399   let Inst{10-6}  = fd;
400   let Inst{5}     = 0;
401   let Inst{4-0}   = Cond.Value;
402 }
403