1 //=- Mips32r6InstrFormats.td - Mips32r6 Instruction Formats -*- tablegen -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes Mips32r6 instruction formats.
12 //===----------------------------------------------------------------------===//
14 class MipsR6Inst : MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther>,
16 let DecoderNamespace = "Mips32r6_64r6";
17 let EncodingPredicates = [HasStdEnc];
20 //===----------------------------------------------------------------------===//
24 //===----------------------------------------------------------------------===//
26 class OPGROUP<bits<6> Val> {
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>;
44 class OPCODE2<bits<2> Val> {
47 def OPCODE2_ADDIUPC : OPCODE2<0b00>;
48 def OPCODE2_LWPC : OPCODE2<0b01>;
49 def OPCODE2_LWUPC : OPCODE2<0b10>;
51 class OPCODE3<bits<3> Val> {
54 def OPCODE3_LDPC : OPCODE3<0b110>;
56 class OPCODE5<bits<5> Val> {
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 def OPCODE5_BGEZAL : OPCODE5<0b10001>;
69 class OPCODE6<bits<6> Val> {
72 def OPCODE6_ALIGN : OPCODE6<0b100000>;
73 def OPCODE6_DALIGN : OPCODE6<0b100100>;
74 def OPCODE6_BITSWAP : OPCODE6<0b100000>;
75 def OPCODE6_DBITSWAP : OPCODE6<0b100100>;
76 def OPCODE6_JALR : OPCODE6<0b001001>;
77 def OPCODE6_CACHE : OPCODE6<0b100101>;
78 def OPCODE6_PREF : OPCODE6<0b110101>;
80 class FIELD_FMT<bits<5> Val> {
83 def FIELD_FMT_S : FIELD_FMT<0b10000>;
84 def FIELD_FMT_D : FIELD_FMT<0b10001>;
86 class FIELD_CMP_COND<bits<5> Val> {
89 def FIELD_CMP_COND_F : FIELD_CMP_COND<0b00000>;
90 def FIELD_CMP_COND_UN : FIELD_CMP_COND<0b00001>;
91 def FIELD_CMP_COND_EQ : FIELD_CMP_COND<0b00010>;
92 def FIELD_CMP_COND_UEQ : FIELD_CMP_COND<0b00011>;
93 def FIELD_CMP_COND_OLT : FIELD_CMP_COND<0b00100>;
94 def FIELD_CMP_COND_ULT : FIELD_CMP_COND<0b00101>;
95 def FIELD_CMP_COND_OLE : FIELD_CMP_COND<0b00110>;
96 def FIELD_CMP_COND_ULE : FIELD_CMP_COND<0b00111>;
97 def FIELD_CMP_COND_SF : FIELD_CMP_COND<0b01000>;
98 def FIELD_CMP_COND_NGLE : FIELD_CMP_COND<0b01001>;
99 def FIELD_CMP_COND_SEQ : FIELD_CMP_COND<0b01010>;
100 def FIELD_CMP_COND_NGL : FIELD_CMP_COND<0b01011>;
101 def FIELD_CMP_COND_LT : FIELD_CMP_COND<0b01100>;
102 def FIELD_CMP_COND_NGE : FIELD_CMP_COND<0b01101>;
103 def FIELD_CMP_COND_LE : FIELD_CMP_COND<0b01110>;
104 def FIELD_CMP_COND_NGT : FIELD_CMP_COND<0b01111>;
106 class FIELD_CMP_FORMAT<bits<5> Val> {
109 def FIELD_CMP_FORMAT_S : FIELD_CMP_FORMAT<0b10100>;
110 def FIELD_CMP_FORMAT_D : FIELD_CMP_FORMAT<0b10101>;
112 //===----------------------------------------------------------------------===//
116 //===----------------------------------------------------------------------===//
118 // Some encodings are ambiguous except by comparing field values.
120 class DecodeDisambiguates<string Name> {
121 string DecoderMethod = !strconcat("Decode", Name);
124 class DecodeDisambiguatedBy<string Name> : DecodeDisambiguates<Name> {
125 string DecoderNamespace = "Mips32r6_64r6_Ambiguous";
128 //===----------------------------------------------------------------------===//
132 //===----------------------------------------------------------------------===//
134 class AUI_FM : MipsR6Inst {
141 let Inst{31-26} = OPGROUP_AUI.Value;
142 let Inst{25-21} = rs;
143 let Inst{20-16} = rt;
144 let Inst{15-0} = imm;
147 class DAUI_FM : AUI_FM {
148 let Inst{31-26} = OPGROUP_DAUI.Value;
151 class BAL_FM : MipsR6Inst {
156 let Inst{31-26} = OPGROUP_REGIMM.Value;
157 let Inst{25-21} = 0b00000;
158 let Inst{20-16} = OPCODE5_BGEZAL.Value;
159 let Inst{15-0} = offset;
162 class COP1_2R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
168 let Inst{31-26} = OPGROUP_COP1.Value;
169 let Inst{25-21} = Format.Value;
170 let Inst{20-16} = 0b00000;
171 let Inst{15-11} = fs;
173 let Inst{5-0} = funct;
176 class COP1_3R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
183 let Inst{31-26} = OPGROUP_COP1.Value;
184 let Inst{25-21} = Format.Value;
185 let Inst{20-16} = ft;
186 let Inst{15-11} = fs;
188 let Inst{5-0} = funct;
191 class COP1_BCCZ_FM<OPCODE5 Operation> : MipsR6Inst {
197 let Inst{31-26} = OPGROUP_COP1.Value;
198 let Inst{25-21} = Operation.Value;
199 let Inst{20-16} = ft;
200 let Inst{15-0} = offset;
203 class COP2_BCCZ_FM<OPCODE5 Operation> : MipsR6Inst {
209 let Inst{31-26} = OPGROUP_COP2.Value;
210 let Inst{25-21} = Operation.Value;
211 let Inst{20-16} = ct;
212 let Inst{15-0} = offset;
215 class PCREL16_FM<OPCODE5 Operation> : MipsR6Inst {
221 let Inst{31-26} = OPGROUP_PCREL.Value;
222 let Inst{25-21} = rs;
223 let Inst{20-16} = Operation.Value;
224 let Inst{15-0} = imm;
227 class PCREL19_FM<OPCODE2 Operation> : MipsR6Inst {
233 let Inst{31-26} = OPGROUP_PCREL.Value;
234 let Inst{25-21} = rs;
235 let Inst{20-19} = Operation.Value;
236 let Inst{18-0} = imm;
239 class PCREL18_FM<OPCODE3 Operation> : MipsR6Inst {
245 let Inst{31-26} = OPGROUP_PCREL.Value;
246 let Inst{25-21} = rs;
247 let Inst{20-18} = Operation.Value;
248 let Inst{17-0} = imm;
251 class SPECIAL3_2R_FM<OPCODE6 Operation> : MipsR6Inst {
257 let Inst{31-26} = OPGROUP_SPECIAL3.Value;
258 let Inst{25-21} = 0b00000;
259 let Inst{20-16} = rt;
260 let Inst{15-11} = rd;
261 let Inst{10-6} = 0b00000;
262 let Inst{5-0} = Operation.Value;
265 class SPECIAL3_MEM_FM<OPCODE6 Operation> : MipsR6Inst {
268 bits<5> base = addr{20-16};
269 bits<9> offset = addr{8-0};
273 let Inst{31-26} = OPGROUP_SPECIAL3.Value;
274 let Inst{25-21} = base;
275 let Inst{20-16} = hint;
276 let Inst{15-7} = offset;
278 let Inst{5-0} = Operation.Value;
281 class SPECIAL_3R_FM<bits<5> mulop, bits<6> funct> : MipsR6Inst {
288 let Inst{31-26} = OPGROUP_SPECIAL.Value;
289 let Inst{25-21} = rs;
290 let Inst{20-16} = rt;
291 let Inst{15-11} = rd;
292 let Inst{10-6} = mulop;
293 let Inst{5-0} = funct;
296 // This class is ambiguous with other branches:
297 // BEQC/BNEC require that rs > rt
298 class CMP_BRANCH_2R_OFF16_FM<OPGROUP funct> : MipsR6Inst {
305 let Inst{31-26} = funct.Value;
306 let Inst{25-21} = rs;
307 let Inst{20-16} = rt;
308 let Inst{15-0} = offset;
311 // This class is ambiguous with other branches:
312 // BLEZC/BGEZC/BEQZALC/BNEZALC/BGTZALC require that rs == 0 && rt != 0
313 // The '1R_RT' in the name means 1 register in the rt field.
314 class CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP funct> : MipsR6Inst {
320 let Inst{31-26} = funct.Value;
321 let Inst{25-21} = 0b00000;
322 let Inst{20-16} = rt;
323 let Inst{15-0} = offset;
326 // This class is ambiguous with other branches:
327 // BLTZC/BGTZC/BLTZALC/BGEZALC require that rs == rt && rt != 0
328 // The '1R_BOTH' in the name means 1 register in both the rs and rt fields.
329 class CMP_BRANCH_1R_BOTH_OFF16_FM<OPGROUP funct> : MipsR6Inst {
335 let Inst{31-26} = funct.Value;
336 let Inst{25-21} = rt;
337 let Inst{20-16} = rt;
338 let Inst{15-0} = offset;
341 class CMP_BRANCH_OFF21_FM<bits<6> funct> : MipsR6Inst {
342 bits<5> rs; // rs != 0
347 let Inst{31-26} = funct;
348 let Inst{25-21} = rs;
349 let Inst{20-0} = offset;
352 class JMP_IDX_COMPACT_FM<bits<6> funct> : MipsR6Inst {
358 let Inst{31-26} = funct;
359 let Inst{25-21} = 0b000000;
360 let Inst{20-16} = rt;
361 let Inst{15-0} = offset;
364 class BRANCH_OFF26_FM<bits<6> funct> : MipsR6Inst {
368 let Inst{31-26} = funct;
369 let Inst{25-0} = offset;
372 class SPECIAL3_ALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
380 let Inst{31-26} = OPGROUP_SPECIAL3.Value;
381 let Inst{25-21} = rs;
382 let Inst{20-16} = rt;
383 let Inst{15-11} = rd;
384 let Inst{10-8} = 0b010;
386 let Inst{5-0} = Operation.Value;
389 class SPECIAL3_DALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
397 let Inst{31-26} = OPGROUP_SPECIAL3.Value;
398 let Inst{25-21} = rs;
399 let Inst{20-16} = rt;
400 let Inst{15-11} = rd;
401 let Inst{10-9} = 0b01;
403 let Inst{5-0} = Operation.Value;
406 class REGIMM_FM<OPCODE5 Operation> : MipsR6Inst {
412 let Inst{31-26} = OPGROUP_REGIMM.Value;
413 let Inst{25-21} = rs;
414 let Inst{20-16} = Operation.Value;
415 let Inst{15-0} = imm;
418 class COP1_CMP_CONDN_FM<FIELD_CMP_FORMAT Format,
419 FIELD_CMP_COND Cond> : MipsR6Inst {
426 let Inst{31-26} = OPGROUP_COP1.Value;
427 let Inst{25-21} = Format.Value;
428 let Inst{20-16} = ft;
429 let Inst{15-11} = fs;
432 let Inst{4-0} = Cond.Value;
435 class JR_HB_R6_FM<OPCODE6 Operation> : MipsR6Inst {
440 let Inst{31-26} = OPGROUP_SPECIAL.Value;
441 let Inst{25-21} = rs;
446 let Inst{5-0} = Operation.Value;