1 //=- Mips32r6InstrInfo.td - Mips32r6 Instruction Information -*- tablegen -*-=//
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
7 //===----------------------------------------------------------------------===//
9 // This file describes Mips32r6 instructions.
11 //===----------------------------------------------------------------------===//
13 include "Mips32r6InstrFormats.td"
15 //===----------------------------------------------------------------------===//
17 // Mips profiles and nodes
19 //===----------------------------------------------------------------------===//
21 def SDT_MipsFSelect : SDTypeProfile<1, 3, [SDTCisFP<1>,
25 def MipsFSelect : SDNode<"MipsISD::FSELECT", SDT_MipsFSelect>;
27 //===----------------------------------------------------------------------===//
31 //===----------------------------------------------------------------------===//
33 // Notes about removals/changes from MIPS32r6:
34 // Reencoded: jr -> jalr
35 // Reencoded: jr.hb -> jalr.hb
37 def brtarget21 : Operand<OtherVT> {
38 let EncoderMethod = "getBranchTarget21OpValue";
39 let OperandType = "OPERAND_PCREL";
40 let DecoderMethod = "DecodeBranchTarget21";
41 let ParserMatchClass = MipsJumpTargetAsmOperand;
44 def brtarget26 : Operand<OtherVT> {
45 let EncoderMethod = "getBranchTarget26OpValue";
46 let OperandType = "OPERAND_PCREL";
47 let DecoderMethod = "DecodeBranchTarget26";
48 let ParserMatchClass = MipsJumpTargetAsmOperand;
51 def jmpoffset16 : Operand<OtherVT> {
52 let EncoderMethod = "getJumpOffset16OpValue";
53 let ParserMatchClass = MipsJumpTargetAsmOperand;
56 def calloffset16 : Operand<iPTR> {
57 let EncoderMethod = "getJumpOffset16OpValue";
58 let ParserMatchClass = MipsJumpTargetAsmOperand;
61 //===----------------------------------------------------------------------===//
63 // Instruction Encodings
65 //===----------------------------------------------------------------------===//
67 class ADDIUPC_ENC : PCREL19_FM<OPCODE2_ADDIUPC>;
68 class ALIGN_ENC : SPECIAL3_ALIGN_FM<OPCODE6_ALIGN>;
69 class ALUIPC_ENC : PCREL16_FM<OPCODE5_ALUIPC>;
70 class AUI_ENC : AUI_FM;
71 class AUIPC_ENC : PCREL16_FM<OPCODE5_AUIPC>;
73 class BAL_ENC : BAL_FM;
74 class BALC_ENC : BRANCH_OFF26_FM<0b111010>;
75 class BC_ENC : BRANCH_OFF26_FM<0b110010>;
76 class BEQC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_ADDI>,
77 DecodeDisambiguates<"AddiGroupBranch">;
78 class BEQZALC_ENC : CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP_ADDI>,
79 DecodeDisambiguatedBy<"DaddiGroupBranch">;
80 class BNEC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_DADDI>,
81 DecodeDisambiguates<"DaddiGroupBranch">;
82 class BNEZALC_ENC : CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP_DADDI>,
83 DecodeDisambiguatedBy<"DaddiGroupBranch">;
85 class BLTZC_ENC : CMP_BRANCH_1R_BOTH_OFF16_FM<OPGROUP_BGTZL>,
86 DecodeDisambiguates<"BgtzlGroupBranch">;
87 class BGEC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_BLEZL>,
88 DecodeDisambiguatedBy<"BlezlGroupBranch">;
89 class BGEUC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_BLEZ>,
90 DecodeDisambiguatedBy<"BlezGroupBranch">;
91 class BGEZC_ENC : CMP_BRANCH_1R_BOTH_OFF16_FM<OPGROUP_BLEZL>,
92 DecodeDisambiguates<"BlezlGroupBranch">;
93 class BGTZALC_ENC : CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP_BGTZ>,
94 DecodeDisambiguatedBy<"BgtzGroupBranch">;
96 class BLTC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_BGTZL>,
97 DecodeDisambiguatedBy<"BgtzlGroupBranch">;
98 class BLTUC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_BGTZ>,
99 DecodeDisambiguatedBy<"BgtzGroupBranch">;
101 class BLEZC_ENC : CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP_BLEZL>,
102 DecodeDisambiguatedBy<"BlezlGroupBranch">;
103 class BLTZALC_ENC : CMP_BRANCH_1R_BOTH_OFF16_FM<OPGROUP_BGTZ>,
104 DecodeDisambiguates<"BgtzGroupBranch">;
105 class BGTZC_ENC : CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP_BGTZL>,
106 DecodeDisambiguatedBy<"BgtzlGroupBranch">;
108 class BEQZC_ENC : CMP_BRANCH_OFF21_FM<0b110110>;
109 class BGEZALC_ENC : CMP_BRANCH_1R_BOTH_OFF16_FM<OPGROUP_BLEZ>,
110 DecodeDisambiguates<"BlezGroupBranch">;
111 class BNEZC_ENC : CMP_BRANCH_OFF21_FM<0b111110>;
113 class BC1EQZ_ENC : COP1_BCCZ_FM<OPCODE5_BC1EQZ>;
114 class BC1NEZ_ENC : COP1_BCCZ_FM<OPCODE5_BC1NEZ>;
115 class BC2EQZ_ENC : COP2_BCCZ_FM<OPCODE5_BC2EQZ>;
116 class BC2NEZ_ENC : COP2_BCCZ_FM<OPCODE5_BC2NEZ>;
118 class DVP_ENC : COP0_EVP_DVP_FM<0b1>;
119 class EVP_ENC : COP0_EVP_DVP_FM<0b0>;
121 class JIALC_ENC : JMP_IDX_COMPACT_FM<0b111110>;
122 class JIC_ENC : JMP_IDX_COMPACT_FM<0b110110>;
123 class JR_HB_R6_ENC : JR_HB_R6_FM<OPCODE6_JALR>;
124 class BITSWAP_ENC : SPECIAL3_2R_FM<OPCODE6_BITSWAP>;
125 class BLEZALC_ENC : CMP_BRANCH_1R_RT_OFF16_FM<OPGROUP_BLEZ>,
126 DecodeDisambiguatedBy<"BlezGroupBranch">;
127 class BNVC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_DADDI>,
128 DecodeDisambiguatedBy<"DaddiGroupBranch">;
129 class BOVC_ENC : CMP_BRANCH_2R_OFF16_FM<OPGROUP_ADDI>,
130 DecodeDisambiguatedBy<"AddiGroupBranch">;
131 class DIV_ENC : SPECIAL_3R_FM<0b00010, 0b011010>;
132 class DIVU_ENC : SPECIAL_3R_FM<0b00010, 0b011011>;
133 class MOD_ENC : SPECIAL_3R_FM<0b00011, 0b011010>;
134 class MODU_ENC : SPECIAL_3R_FM<0b00011, 0b011011>;
135 class MUH_ENC : SPECIAL_3R_FM<0b00011, 0b011000>;
136 class MUHU_ENC : SPECIAL_3R_FM<0b00011, 0b011001>;
137 class MUL_R6_ENC : SPECIAL_3R_FM<0b00010, 0b011000>;
138 class MULU_ENC : SPECIAL_3R_FM<0b00010, 0b011001>;
140 class MADDF_S_ENC : COP1_3R_FM<0b011000, FIELD_FMT_S>;
141 class MADDF_D_ENC : COP1_3R_FM<0b011000, FIELD_FMT_D>;
142 class MSUBF_S_ENC : COP1_3R_FM<0b011001, FIELD_FMT_S>;
143 class MSUBF_D_ENC : COP1_3R_FM<0b011001, FIELD_FMT_D>;
145 class SEL_D_ENC : COP1_3R_FM<0b010000, FIELD_FMT_D>;
146 class SEL_S_ENC : COP1_3R_FM<0b010000, FIELD_FMT_S>;
148 class SELEQZ_ENC : SPECIAL_3R_FM<0b00000, 0b110101>;
149 class SELNEZ_ENC : SPECIAL_3R_FM<0b00000, 0b110111>;
151 class LWPC_ENC : PCREL19_FM<OPCODE2_LWPC>;
153 class MAX_S_ENC : COP1_3R_FM<0b011101, FIELD_FMT_S>;
154 class MAX_D_ENC : COP1_3R_FM<0b011101, FIELD_FMT_D>;
155 class MIN_S_ENC : COP1_3R_FM<0b011100, FIELD_FMT_S>;
156 class MIN_D_ENC : COP1_3R_FM<0b011100, FIELD_FMT_D>;
158 class MAXA_S_ENC : COP1_3R_FM<0b011111, FIELD_FMT_S>;
159 class MAXA_D_ENC : COP1_3R_FM<0b011111, FIELD_FMT_D>;
160 class MINA_S_ENC : COP1_3R_FM<0b011110, FIELD_FMT_S>;
161 class MINA_D_ENC : COP1_3R_FM<0b011110, FIELD_FMT_D>;
163 class SELEQZ_S_ENC : COP1_3R_FM<0b010100, FIELD_FMT_S>;
164 class SELEQZ_D_ENC : COP1_3R_FM<0b010100, FIELD_FMT_D>;
165 class SELNEZ_S_ENC : COP1_3R_FM<0b010111, FIELD_FMT_S>;
166 class SELNEZ_D_ENC : COP1_3R_FM<0b010111, FIELD_FMT_D>;
168 class RINT_S_ENC : COP1_2R_FM<0b011010, FIELD_FMT_S>;
169 class RINT_D_ENC : COP1_2R_FM<0b011010, FIELD_FMT_D>;
170 class CLASS_S_ENC : COP1_2R_FM<0b011011, FIELD_FMT_S>;
171 class CLASS_D_ENC : COP1_2R_FM<0b011011, FIELD_FMT_D>;
173 class CACHE_ENC : SPECIAL3_MEM_FM<OPCODE6_CACHE>;
174 class PREF_ENC : SPECIAL3_MEM_FM<OPCODE6_PREF>;
176 class LDC2_R6_ENC : COP2LDST_FM<OPCODE5_LDC2>;
177 class LWC2_R6_ENC : COP2LDST_FM<OPCODE5_LWC2>;
178 class SDC2_R6_ENC : COP2LDST_FM<OPCODE5_SDC2>;
179 class SWC2_R6_ENC : COP2LDST_FM<OPCODE5_SWC2>;
181 class LSA_R6_ENC : SPECIAL_LSA_FM<OPCODE6_LSA>;
183 class LL_R6_ENC : SPECIAL3_LL_SC_FM<OPCODE6_LL>;
184 class SC_R6_ENC : SPECIAL3_LL_SC_FM<OPCODE6_SC>;
186 class CLO_R6_ENC : SPECIAL_2R_FM<OPCODE6_CLO>;
187 class CLZ_R6_ENC : SPECIAL_2R_FM<OPCODE6_CLZ>;
189 class SDBBP_R6_ENC : SPECIAL_SDBBP_FM;
191 class CRC32B_ENC : SPECIAL3_2R_SZ_CRC<0,0>;
192 class CRC32H_ENC : SPECIAL3_2R_SZ_CRC<1,0>;
193 class CRC32W_ENC : SPECIAL3_2R_SZ_CRC<2,0>;
194 class CRC32CB_ENC : SPECIAL3_2R_SZ_CRC<0,1>;
195 class CRC32CH_ENC : SPECIAL3_2R_SZ_CRC<1,1>;
196 class CRC32CW_ENC : SPECIAL3_2R_SZ_CRC<2,1>;
198 class GINVI_ENC : SPECIAL3_GINV<0>;
199 class GINVT_ENC : SPECIAL3_GINV<2>;
201 class SIGRIE_ENC : SIGRIE_FM;
203 //===----------------------------------------------------------------------===//
205 // Instruction Multiclasses
207 //===----------------------------------------------------------------------===//
209 class CMP_CONDN_DESC_BASE<string CondStr, string Typestr,
210 RegisterOperand FGROpnd,
212 SDPatternOperator Op = null_frag> {
213 dag OutOperandList = (outs FGRCCOpnd:$fd);
214 dag InOperandList = (ins FGROpnd:$fs, FGROpnd:$ft);
215 string AsmString = !strconcat("cmp.", CondStr, ".", Typestr, "\t$fd, $fs, $ft");
216 list<dag> Pattern = [(set FGRCCOpnd:$fd, (Op FGROpnd:$fs, FGROpnd:$ft))];
218 InstrItinClass Itinerary = Itin;
221 multiclass CMP_CC_M <FIELD_CMP_FORMAT Format, string Typestr,
222 RegisterOperand FGROpnd, InstrItinClass Itin>{
223 let AdditionalPredicates = [NotInMicroMips] in {
224 def CMP_F_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format, FIELD_CMP_COND_AF>,
225 CMP_CONDN_DESC_BASE<"af", Typestr, FGROpnd, Itin>,
226 MipsR6Arch<!strconcat("cmp.af.", Typestr)>,
227 ISA_MIPS32R6, HARDFLOAT;
228 def CMP_UN_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format, FIELD_CMP_COND_UN>,
229 CMP_CONDN_DESC_BASE<"un", Typestr, FGROpnd, Itin, setuo>,
230 MipsR6Arch<!strconcat("cmp.un.", Typestr)>,
231 ISA_MIPS32R6, HARDFLOAT;
232 def CMP_EQ_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format, FIELD_CMP_COND_EQ>,
233 CMP_CONDN_DESC_BASE<"eq", Typestr, FGROpnd, Itin,
235 MipsR6Arch<!strconcat("cmp.eq.", Typestr)>,
236 ISA_MIPS32R6, HARDFLOAT;
237 def CMP_UEQ_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
239 CMP_CONDN_DESC_BASE<"ueq", Typestr, FGROpnd, Itin,
241 MipsR6Arch<!strconcat("cmp.ueq.", Typestr)>,
242 ISA_MIPS32R6, HARDFLOAT;
243 def CMP_LT_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format, FIELD_CMP_COND_LT>,
244 CMP_CONDN_DESC_BASE<"lt", Typestr, FGROpnd, Itin,
246 MipsR6Arch<!strconcat("cmp.lt.", Typestr)>,
247 ISA_MIPS32R6, HARDFLOAT;
248 def CMP_ULT_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
250 CMP_CONDN_DESC_BASE<"ult", Typestr, FGROpnd, Itin,
252 MipsR6Arch<!strconcat("cmp.ult.", Typestr)>,
253 ISA_MIPS32R6, HARDFLOAT;
254 def CMP_LE_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format, FIELD_CMP_COND_LE>,
255 CMP_CONDN_DESC_BASE<"le", Typestr, FGROpnd, Itin,
257 MipsR6Arch<!strconcat("cmp.le.", Typestr)>,
258 ISA_MIPS32R6, HARDFLOAT;
259 def CMP_ULE_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
261 CMP_CONDN_DESC_BASE<"ule", Typestr, FGROpnd, Itin,
263 MipsR6Arch<!strconcat("cmp.ule.", Typestr)>,
264 ISA_MIPS32R6, HARDFLOAT;
265 def CMP_SAF_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
267 CMP_CONDN_DESC_BASE<"saf", Typestr, FGROpnd, Itin>,
268 MipsR6Arch<!strconcat("cmp.saf.", Typestr)>,
269 ISA_MIPS32R6, HARDFLOAT;
270 def CMP_SUN_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
272 CMP_CONDN_DESC_BASE<"sun", Typestr, FGROpnd, Itin>,
273 MipsR6Arch<!strconcat("cmp.sun.", Typestr)>,
274 ISA_MIPS32R6, HARDFLOAT;
275 def CMP_SEQ_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
277 CMP_CONDN_DESC_BASE<"seq", Typestr, FGROpnd, Itin>,
278 MipsR6Arch<!strconcat("cmp.seq.", Typestr)>,
279 ISA_MIPS32R6, HARDFLOAT;
280 def CMP_SUEQ_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
281 FIELD_CMP_COND_SUEQ>,
282 CMP_CONDN_DESC_BASE<"sueq", Typestr, FGROpnd, Itin>,
283 MipsR6Arch<!strconcat("cmp.sueq.", Typestr)>,
284 ISA_MIPS32R6, HARDFLOAT;
285 def CMP_SLT_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
287 CMP_CONDN_DESC_BASE<"slt", Typestr, FGROpnd, Itin>,
288 MipsR6Arch<!strconcat("cmp.slt.", Typestr)>,
289 ISA_MIPS32R6, HARDFLOAT;
290 def CMP_SULT_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
291 FIELD_CMP_COND_SULT>,
292 CMP_CONDN_DESC_BASE<"sult", Typestr, FGROpnd, Itin>,
293 MipsR6Arch<!strconcat("cmp.sult.", Typestr)>,
294 ISA_MIPS32R6, HARDFLOAT;
295 def CMP_SLE_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
297 CMP_CONDN_DESC_BASE<"sle", Typestr, FGROpnd, Itin>,
298 MipsR6Arch<!strconcat("cmp.sle.", Typestr)>,
299 ISA_MIPS32R6, HARDFLOAT;
300 def CMP_SULE_#NAME : R6MMR6Rel, COP1_CMP_CONDN_FM<Format,
301 FIELD_CMP_COND_SULE>,
302 CMP_CONDN_DESC_BASE<"sule", Typestr, FGROpnd, Itin>,
303 MipsR6Arch<!strconcat("cmp.sule.", Typestr)>,
304 ISA_MIPS32R6, HARDFLOAT;
308 //===----------------------------------------------------------------------===//
310 // Instruction Descriptions
312 //===----------------------------------------------------------------------===//
314 class PCREL_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
315 Operand ImmOpnd, InstrItinClass itin>
316 : MipsR6Arch<instr_asm> {
317 dag OutOperandList = (outs GPROpnd:$rs);
318 dag InOperandList = (ins ImmOpnd:$imm);
319 string AsmString = !strconcat(instr_asm, "\t$rs, $imm");
320 list<dag> Pattern = [];
321 InstrItinClass Itinerary = itin;
324 class ADDIUPC_DESC : PCREL_DESC_BASE<"addiupc", GPR32Opnd, simm19_lsl2,
326 class LWPC_DESC: PCREL_DESC_BASE<"lwpc", GPR32Opnd, simm19_lsl2, II_LWPC>;
328 class ALIGN_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
329 Operand ImmOpnd, InstrItinClass itin>
330 : MipsR6Arch<instr_asm> {
331 dag OutOperandList = (outs GPROpnd:$rd);
332 dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt, ImmOpnd:$bp);
333 string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt, $bp");
334 list<dag> Pattern = [];
335 InstrItinClass Itinerary = itin;
338 class ALIGN_DESC : ALIGN_DESC_BASE<"align", GPR32Opnd, uimm2, II_ALIGN>;
340 class ALUIPC_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
341 InstrItinClass itin = NoItinerary>
342 : MipsR6Arch<instr_asm> {
343 dag OutOperandList = (outs GPROpnd:$rs);
344 dag InOperandList = (ins simm16:$imm);
345 string AsmString = !strconcat(instr_asm, "\t$rs, $imm");
346 list<dag> Pattern = [];
347 InstrItinClass Itinerary = itin;
350 class ALUIPC_DESC : ALUIPC_DESC_BASE<"aluipc", GPR32Opnd, II_ALUIPC>;
351 class AUIPC_DESC : ALUIPC_DESC_BASE<"auipc", GPR32Opnd, II_AUIPC>;
353 class AUI_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
354 InstrItinClass itin = NoItinerary>
355 : MipsR6Arch<instr_asm> {
356 dag OutOperandList = (outs GPROpnd:$rt);
357 dag InOperandList = (ins GPROpnd:$rs, uimm16:$imm);
358 string AsmString = !strconcat(instr_asm, "\t$rt, $rs, $imm");
359 list<dag> Pattern = [];
360 InstrItinClass Itinerary = itin;
363 class AUI_DESC : AUI_DESC_BASE<"aui", GPR32Opnd, II_AUI>;
365 class BRANCH_DESC_BASE {
367 bit isTerminator = 1;
368 bit hasDelaySlot = 0;
372 class BC_DESC_BASE<string instr_asm, DAGOperand opnd> : BRANCH_DESC_BASE,
373 MipsR6Arch<instr_asm> {
374 dag InOperandList = (ins opnd:$offset);
375 dag OutOperandList = (outs);
376 string AsmString = !strconcat(instr_asm, "\t$offset");
378 InstrItinClass Itinerary = II_BC;
382 class CMP_BC_DESC_BASE<string instr_asm, DAGOperand opnd,
383 RegisterOperand GPROpnd> : BRANCH_DESC_BASE,
384 MipsR6Arch<instr_asm> {
385 dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt, opnd:$offset);
386 dag OutOperandList = (outs);
387 string AsmString = !strconcat(instr_asm, "\t$rs, $rt, $offset");
388 list<Register> Defs = [AT];
389 InstrItinClass Itinerary = II_BCCC;
390 bit hasForbiddenSlot = 1;
394 class CMP_CBR_EQNE_Z_DESC_BASE<string instr_asm, DAGOperand opnd,
395 RegisterOperand GPROpnd>
396 : BRANCH_DESC_BASE, MipsR6Arch<instr_asm> {
397 dag InOperandList = (ins GPROpnd:$rs, opnd:$offset);
398 dag OutOperandList = (outs);
399 string AsmString = !strconcat(instr_asm, "\t$rs, $offset");
400 list<Register> Defs = [AT];
401 InstrItinClass Itinerary = II_BCCZC;
402 bit hasForbiddenSlot = 1;
406 class CMP_CBR_RT_Z_DESC_BASE<string instr_asm, DAGOperand opnd,
407 RegisterOperand GPROpnd>
408 : BRANCH_DESC_BASE, MipsR6Arch<instr_asm> {
409 dag InOperandList = (ins GPROpnd:$rt, opnd:$offset);
410 dag OutOperandList = (outs);
411 string AsmString = !strconcat(instr_asm, "\t$rt, $offset");
412 list<Register> Defs = [AT];
413 InstrItinClass Itinerary = II_BCCZC;
414 bit hasForbiddenSlot = 1;
418 class BAL_DESC : BC_DESC_BASE<"bal", brtarget> {
420 bit hasDelaySlot = 1;
421 list<Register> Defs = [RA];
425 class BALC_DESC : BC_DESC_BASE<"balc", brtarget26> {
427 list<Register> Defs = [RA];
428 InstrItinClass Itinerary = II_BALC;
432 class BC_DESC : BC_DESC_BASE<"bc", brtarget26>;
433 class BGEC_DESC : CMP_BC_DESC_BASE<"bgec", brtarget, GPR32Opnd>;
434 class BGEUC_DESC : CMP_BC_DESC_BASE<"bgeuc", brtarget, GPR32Opnd>;
435 class BEQC_DESC : CMP_BC_DESC_BASE<"beqc", brtarget, GPR32Opnd>;
436 class BNEC_DESC : CMP_BC_DESC_BASE<"bnec", brtarget, GPR32Opnd>;
438 class BLTC_DESC : CMP_BC_DESC_BASE<"bltc", brtarget, GPR32Opnd>;
439 class BLTUC_DESC : CMP_BC_DESC_BASE<"bltuc", brtarget, GPR32Opnd>;
441 class BLTZC_DESC : CMP_CBR_RT_Z_DESC_BASE<"bltzc", brtarget, GPR32Opnd>;
442 class BGEZC_DESC : CMP_CBR_RT_Z_DESC_BASE<"bgezc", brtarget, GPR32Opnd>;
444 class BLEZC_DESC : CMP_CBR_RT_Z_DESC_BASE<"blezc", brtarget, GPR32Opnd>;
445 class BGTZC_DESC : CMP_CBR_RT_Z_DESC_BASE<"bgtzc", brtarget, GPR32Opnd>;
447 class BEQZC_DESC : CMP_CBR_EQNE_Z_DESC_BASE<"beqzc", brtarget21, GPR32Opnd>;
448 class BNEZC_DESC : CMP_CBR_EQNE_Z_DESC_BASE<"bnezc", brtarget21, GPR32Opnd>;
450 class COP1_BCCZ_DESC_BASE<string instr_asm> : BRANCH_DESC_BASE {
451 dag InOperandList = (ins FGR64Opnd:$ft, brtarget:$offset);
452 dag OutOperandList = (outs);
453 string AsmString = instr_asm;
454 bit hasDelaySlot = 1;
455 InstrItinClass Itinerary = II_BC1CCZ;
458 class BC1EQZ_DESC : COP1_BCCZ_DESC_BASE<"bc1eqz $ft, $offset">;
459 class BC1NEZ_DESC : COP1_BCCZ_DESC_BASE<"bc1nez $ft, $offset">;
461 class COP2_BCCZ_DESC_BASE<string instr_asm> : BRANCH_DESC_BASE {
462 dag InOperandList = (ins COP2Opnd:$ct, brtarget:$offset);
463 dag OutOperandList = (outs);
464 string AsmString = instr_asm;
465 bit hasDelaySlot = 1;
467 InstrItinClass Itinerary = II_BC2CCZ;
470 class BC2EQZ_DESC : COP2_BCCZ_DESC_BASE<"bc2eqz $ct, $offset">;
471 class BC2NEZ_DESC : COP2_BCCZ_DESC_BASE<"bc2nez $ct, $offset">;
473 class BOVC_DESC : CMP_BC_DESC_BASE<"bovc", brtarget, GPR32Opnd>;
474 class BNVC_DESC : CMP_BC_DESC_BASE<"bnvc", brtarget, GPR32Opnd>;
476 class JMP_IDX_COMPACT_DESC_BASE<string opstr, DAGOperand opnd,
477 RegisterOperand GPROpnd,
478 InstrItinClass itin = NoItinerary>
479 : MipsR6Arch<opstr> {
480 dag InOperandList = (ins GPROpnd:$rt, opnd:$offset);
481 string AsmString = !strconcat(opstr, "\t$rt, $offset");
482 list<dag> Pattern = [];
483 bit hasDelaySlot = 0;
484 InstrItinClass Itinerary = itin;
487 bit isIndirectBranch = 1;
490 class JIALC_DESC : JMP_IDX_COMPACT_DESC_BASE<"jialc", calloffset16,
491 GPR32Opnd, II_JIALC> {
493 list<Register> Defs = [RA];
496 class JIC_DESC : JMP_IDX_COMPACT_DESC_BASE<"jic", jmpoffset16,
497 GPR32Opnd, II_JIALC> {
499 bit isTerminator = 1;
500 list<Register> Defs = [AT];
503 class JR_HB_R6_DESC : JR_HB_DESC_BASE<"jr.hb", GPR32Opnd> {
505 bit isIndirectBranch = 1;
506 bit hasDelaySlot = 1;
510 InstrItinClass Itinerary = II_JR_HB;
513 class BITSWAP_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
515 : MipsR6Arch<instr_asm> {
516 dag OutOperandList = (outs GPROpnd:$rd);
517 dag InOperandList = (ins GPROpnd:$rt);
518 string AsmString = !strconcat(instr_asm, "\t$rd, $rt");
519 list<dag> Pattern = [];
520 InstrItinClass Itinerary = itin;
523 class BITSWAP_DESC : BITSWAP_DESC_BASE<"bitswap", GPR32Opnd, II_BITSWAP>;
525 class DIVMOD_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
527 SDPatternOperator Op=null_frag>
528 : MipsR6Arch<instr_asm> {
529 dag OutOperandList = (outs GPROpnd:$rd);
530 dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt);
531 string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
532 list<dag> Pattern = [(set GPROpnd:$rd, (Op GPROpnd:$rs, GPROpnd:$rt))];
533 InstrItinClass Itinerary = itin;
534 // This instruction doesn't trap division by zero itself. We must insert
535 // teq instructions as well.
536 bit usesCustomInserter = 1;
539 class DVPEVP_DESC_BASE<string instr_asm, InstrItinClass Itin>
540 : MipsR6Arch<instr_asm> {
541 dag OutOperandList = (outs GPR32Opnd:$rt);
542 dag InOperandList = (ins);
543 string AsmString = !strconcat(instr_asm, "\t$rt");
544 list<dag> Pattern = [];
545 InstrItinClass Itinerary = Itin;
546 bit hasUnModeledSideEffects = 1;
549 class DVP_DESC : DVPEVP_DESC_BASE<"dvp", II_DVP>;
550 class EVP_DESC : DVPEVP_DESC_BASE<"evp", II_EVP>;
552 class DIV_DESC : DIVMOD_DESC_BASE<"div", GPR32Opnd, II_DIV, sdiv>;
553 class DIVU_DESC : DIVMOD_DESC_BASE<"divu", GPR32Opnd, II_DIVU, udiv>;
554 class MOD_DESC : DIVMOD_DESC_BASE<"mod", GPR32Opnd, II_MOD, srem>;
555 class MODU_DESC : DIVMOD_DESC_BASE<"modu", GPR32Opnd, II_MODU, urem>;
557 class BEQZALC_DESC : CMP_CBR_RT_Z_DESC_BASE<"beqzalc", brtarget, GPR32Opnd> {
558 list<Register> Defs = [RA];
561 class BGEZALC_DESC : CMP_CBR_RT_Z_DESC_BASE<"bgezalc", brtarget, GPR32Opnd> {
562 list<Register> Defs = [RA];
565 class BGTZALC_DESC : CMP_CBR_RT_Z_DESC_BASE<"bgtzalc", brtarget, GPR32Opnd> {
566 list<Register> Defs = [RA];
569 class BLEZALC_DESC : CMP_CBR_RT_Z_DESC_BASE<"blezalc", brtarget, GPR32Opnd> {
570 list<Register> Defs = [RA];
573 class BLTZALC_DESC : CMP_CBR_RT_Z_DESC_BASE<"bltzalc", brtarget, GPR32Opnd> {
574 list<Register> Defs = [RA];
577 class BNEZALC_DESC : CMP_CBR_RT_Z_DESC_BASE<"bnezalc", brtarget, GPR32Opnd> {
578 list<Register> Defs = [RA];
581 class MUL_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
583 SDPatternOperator Op=null_frag> : MipsR6Arch<instr_asm> {
584 dag OutOperandList = (outs GPROpnd:$rd);
585 dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt);
586 string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
587 list<dag> Pattern = [(set GPROpnd:$rd, (Op GPROpnd:$rs, GPROpnd:$rt))];
588 InstrItinClass Itinerary = itin;
591 class MUH_DESC : MUL_R6_DESC_BASE<"muh", GPR32Opnd, II_MUH, mulhs>;
592 class MUHU_DESC : MUL_R6_DESC_BASE<"muhu", GPR32Opnd, II_MUHU, mulhu>;
593 class MUL_R6_DESC : MUL_R6_DESC_BASE<"mul", GPR32Opnd, II_MUL, mul>;
594 class MULU_DESC : MUL_R6_DESC_BASE<"mulu", GPR32Opnd, II_MULU>;
596 class COP1_SEL_DESC_BASE<string instr_asm, RegisterOperand FGROpnd,
597 InstrItinClass itin> {
598 dag OutOperandList = (outs FGROpnd:$fd);
599 dag InOperandList = (ins FGRCCOpnd:$fd_in, FGROpnd:$fs, FGROpnd:$ft);
600 string AsmString = !strconcat(instr_asm, "\t$fd, $fs, $ft");
601 list<dag> Pattern = [(set FGROpnd:$fd, (select FGRCCOpnd:$fd_in,
604 string Constraints = "$fd_in = $fd";
605 InstrItinClass Itinerary = itin;
608 class COP1_SEL_D_DESC_BASE<string instr_asm, RegisterOperand FGROpnd,
609 InstrItinClass itin> {
610 dag OutOperandList = (outs FGROpnd:$fd);
611 dag InOperandList = (ins FGROpnd:$fd_in, FGROpnd:$fs, FGROpnd:$ft);
612 string AsmString = !strconcat(instr_asm, "\t$fd, $fs, $ft");
613 list<dag> Pattern = [(set FGROpnd:$fd, (MipsFSelect FGROpnd:$fd_in,
616 string Constraints = "$fd_in = $fd";
617 InstrItinClass Itinerary = itin;
620 class SEL_D_DESC : COP1_SEL_D_DESC_BASE<"sel.d", FGR64Opnd, II_SEL_D>,
622 class SEL_S_DESC : COP1_SEL_DESC_BASE<"sel.s", FGR32Opnd, II_SEL_S>,
625 class SELEQNE_Z_DESC_BASE<string instr_asm, RegisterOperand GPROpnd>
626 : MipsR6Arch<instr_asm> {
627 dag OutOperandList = (outs GPROpnd:$rd);
628 dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt);
629 string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
630 list<dag> Pattern = [];
631 InstrItinClass Itinerary = II_SELCCZ;
634 class SELEQZ_DESC : SELEQNE_Z_DESC_BASE<"seleqz", GPR32Opnd>;
635 class SELNEZ_DESC : SELEQNE_Z_DESC_BASE<"selnez", GPR32Opnd>;
637 class COP1_4R_DESC_BASE<string instr_asm, RegisterOperand FGROpnd,
638 InstrItinClass itin = NoItinerary> {
639 dag OutOperandList = (outs FGROpnd:$fd);
640 dag InOperandList = (ins FGROpnd:$fd_in, FGROpnd:$fs, FGROpnd:$ft);
641 string AsmString = !strconcat(instr_asm, "\t$fd, $fs, $ft");
642 list<dag> Pattern = [];
643 string Constraints = "$fd_in = $fd";
644 InstrItinClass Itinerary = itin;
647 class MADDF_S_DESC : COP1_4R_DESC_BASE<"maddf.s", FGR32Opnd, II_MADDF_S>;
648 class MADDF_D_DESC : COP1_4R_DESC_BASE<"maddf.d", FGR64Opnd, II_MADDF_D>;
649 class MSUBF_S_DESC : COP1_4R_DESC_BASE<"msubf.s", FGR32Opnd, II_MSUBF_S>;
650 class MSUBF_D_DESC : COP1_4R_DESC_BASE<"msubf.d", FGR64Opnd, II_MSUBF_D>;
652 class MAX_MIN_DESC_BASE<string instr_asm, RegisterOperand FGROpnd,
653 InstrItinClass itin> {
654 dag OutOperandList = (outs FGROpnd:$fd);
655 dag InOperandList = (ins FGROpnd:$fs, FGROpnd:$ft);
656 string AsmString = !strconcat(instr_asm, "\t$fd, $fs, $ft");
657 list<dag> Pattern = [];
658 InstrItinClass Itinerary = itin;
661 class MAX_S_DESC : MAX_MIN_DESC_BASE<"max.s", FGR32Opnd, II_MAX_S>;
662 class MAX_D_DESC : MAX_MIN_DESC_BASE<"max.d", FGR64Opnd, II_MAX_D>;
663 class MIN_S_DESC : MAX_MIN_DESC_BASE<"min.s", FGR32Opnd, II_MIN_S>;
664 class MIN_D_DESC : MAX_MIN_DESC_BASE<"min.d", FGR64Opnd, II_MIN_D>;
666 class MAXA_S_DESC : MAX_MIN_DESC_BASE<"maxa.s", FGR32Opnd, II_MAX_S>;
667 class MAXA_D_DESC : MAX_MIN_DESC_BASE<"maxa.d", FGR64Opnd, II_MAX_D>;
668 class MINA_S_DESC : MAX_MIN_DESC_BASE<"mina.s", FGR32Opnd, II_MIN_D>;
669 class MINA_D_DESC : MAX_MIN_DESC_BASE<"mina.d", FGR64Opnd, II_MIN_S>;
671 class SELEQNEZ_DESC_BASE<string instr_asm, RegisterOperand FGROpnd,
672 InstrItinClass itin> {
673 dag OutOperandList = (outs FGROpnd:$fd);
674 dag InOperandList = (ins FGROpnd:$fs, FGROpnd:$ft);
675 string AsmString = !strconcat(instr_asm, "\t$fd, $fs, $ft");
676 list<dag> Pattern = [];
677 InstrItinClass Itinerary = itin;
680 class SELEQZ_S_DESC : SELEQNEZ_DESC_BASE<"seleqz.s", FGR32Opnd, II_SELCCZ_S>,
681 MipsR6Arch<"seleqz.s">;
682 class SELEQZ_D_DESC : SELEQNEZ_DESC_BASE<"seleqz.d", FGR64Opnd, II_SELCCZ_D>,
683 MipsR6Arch<"seleqz.d">;
684 class SELNEZ_S_DESC : SELEQNEZ_DESC_BASE<"selnez.s", FGR32Opnd, II_SELCCZ_S>,
685 MipsR6Arch<"selnez.s">;
686 class SELNEZ_D_DESC : SELEQNEZ_DESC_BASE<"selnez.d", FGR64Opnd, II_SELCCZ_D>,
687 MipsR6Arch<"selnez.d">;
689 class CLASS_RINT_DESC_BASE<string instr_asm, RegisterOperand FGROpnd,
690 InstrItinClass itin> {
691 dag OutOperandList = (outs FGROpnd:$fd);
692 dag InOperandList = (ins FGROpnd:$fs);
693 string AsmString = !strconcat(instr_asm, "\t$fd, $fs");
694 list<dag> Pattern = [];
695 InstrItinClass Itinerary = itin;
698 class RINT_S_DESC : CLASS_RINT_DESC_BASE<"rint.s", FGR32Opnd, II_RINT_S>;
699 class RINT_D_DESC : CLASS_RINT_DESC_BASE<"rint.d", FGR64Opnd, II_RINT_D>;
700 class CLASS_S_DESC : CLASS_RINT_DESC_BASE<"class.s", FGR32Opnd, II_CLASS_S>;
701 class CLASS_D_DESC : CLASS_RINT_DESC_BASE<"class.d", FGR64Opnd, II_CLASS_D>;
703 class CACHE_HINT_DESC<string instr_asm, Operand MemOpnd,
704 RegisterOperand GPROpnd, InstrItinClass itin>
705 : MipsR6Arch<instr_asm> {
706 dag OutOperandList = (outs);
707 dag InOperandList = (ins MemOpnd:$addr, uimm5:$hint);
708 string AsmString = !strconcat(instr_asm, "\t$hint, $addr");
709 list<dag> Pattern = [];
710 string DecoderMethod = "DecodeCacheeOp_CacheOpR6";
711 InstrItinClass Itinerary = itin;
714 class CACHE_DESC : CACHE_HINT_DESC<"cache", mem_simm9, GPR32Opnd, II_CACHE>;
715 class PREF_DESC : CACHE_HINT_DESC<"pref", mem_simm9, GPR32Opnd, II_PREF>;
717 class COP2LD_DESC_BASE<string instr_asm, RegisterOperand COPOpnd,
718 InstrItinClass itin> {
719 dag OutOperandList = (outs COPOpnd:$rt);
720 dag InOperandList = (ins mem_simm11:$addr);
721 string AsmString = !strconcat(instr_asm, "\t$rt, $addr");
722 list<dag> Pattern = [];
724 string DecoderMethod = "DecodeFMemCop2R6";
725 InstrItinClass Itinerary = itin;
728 class LDC2_R6_DESC : COP2LD_DESC_BASE<"ldc2", COP2Opnd, II_LDC2>;
729 class LWC2_R6_DESC : COP2LD_DESC_BASE<"lwc2", COP2Opnd, II_LWC2>;
731 class COP2ST_DESC_BASE<string instr_asm, RegisterOperand COPOpnd,
732 InstrItinClass itin> {
733 dag OutOperandList = (outs);
734 dag InOperandList = (ins COPOpnd:$rt, mem_simm11:$addr);
735 string AsmString = !strconcat(instr_asm, "\t$rt, $addr");
736 list<dag> Pattern = [];
738 string DecoderMethod = "DecodeFMemCop2R6";
739 InstrItinClass Itinerary = itin;
742 class SDC2_R6_DESC : COP2ST_DESC_BASE<"sdc2", COP2Opnd, II_SDC2>;
743 class SWC2_R6_DESC : COP2ST_DESC_BASE<"swc2", COP2Opnd, II_SWC2>;
745 class LSA_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
746 Operand ImmOpnd, InstrItinClass itin>
747 : MipsR6Arch<instr_asm> {
748 dag OutOperandList = (outs GPROpnd:$rd);
749 dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt, ImmOpnd:$imm2);
750 string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt, $imm2");
751 list<dag> Pattern = [];
752 InstrItinClass Itinerary = itin;
755 class LSA_R6_DESC : LSA_R6_DESC_BASE<"lsa", GPR32Opnd, uimm2_plus1, II_LSA>;
757 class LL_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
758 Operand MemOpnd, InstrItinClass itin>
759 : MipsR6Arch<instr_asm> {
760 dag OutOperandList = (outs GPROpnd:$rt);
761 dag InOperandList = (ins MemOpnd:$addr);
762 string AsmString = !strconcat(instr_asm, "\t$rt, $addr");
763 list<dag> Pattern = [];
765 InstrItinClass Itinerary = itin;
768 class LL_R6_DESC : LL_R6_DESC_BASE<"ll", GPR32Opnd, mem_simm9, II_LL>;
770 class SC_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
771 InstrItinClass itin> {
772 dag OutOperandList = (outs GPROpnd:$dst);
773 dag InOperandList = (ins GPROpnd:$rt, mem_simm9:$addr);
774 string AsmString = !strconcat(instr_asm, "\t$rt, $addr");
775 list<dag> Pattern = [];
777 string Constraints = "$rt = $dst";
778 InstrItinClass Itinerary = itin;
781 class SC_R6_DESC : SC_R6_DESC_BASE<"sc", GPR32Opnd, II_SC>;
783 class CLO_CLZ_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
785 : MipsR6Arch<instr_asm> {
786 dag OutOperandList = (outs GPROpnd:$rd);
787 dag InOperandList = (ins GPROpnd:$rs);
788 string AsmString = !strconcat(instr_asm, "\t$rd, $rs");
789 InstrItinClass Itinerary = itin;
792 class CLO_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
793 InstrItinClass itin> :
794 CLO_CLZ_R6_DESC_BASE<instr_asm, GPROpnd, itin> {
795 list<dag> Pattern = [(set GPROpnd:$rd, (ctlz (not GPROpnd:$rs)))];
798 class CLZ_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
799 InstrItinClass itin> :
800 CLO_CLZ_R6_DESC_BASE<instr_asm, GPROpnd, itin> {
801 list<dag> Pattern = [(set GPROpnd:$rd, (ctlz GPROpnd:$rs))];
804 class CLO_R6_DESC : CLO_R6_DESC_BASE<"clo", GPR32Opnd, II_CLO>;
805 class CLZ_R6_DESC : CLZ_R6_DESC_BASE<"clz", GPR32Opnd, II_CLZ>;
807 class SDBBP_R6_DESC {
808 dag OutOperandList = (outs);
809 dag InOperandList = (ins uimm20:$code_);
810 string AsmString = "sdbbp\t$code_";
811 list<dag> Pattern = [];
813 InstrItinClass Itinerary = II_SDBBP;
816 class CRC_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
817 InstrItinClass itin> : MipsR6Arch<instr_asm> {
818 dag OutOperandList = (outs GPROpnd:$rd);
819 dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt);
820 string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
821 list<dag> Pattern = [];
822 InstrItinClass Itinerary = itin;
825 class CRC32B_DESC : CRC_DESC_BASE<"crc32b", GPR32Opnd, II_CRC32B>;
826 class CRC32H_DESC : CRC_DESC_BASE<"crc32h", GPR32Opnd, II_CRC32H>;
827 class CRC32W_DESC : CRC_DESC_BASE<"crc32w", GPR32Opnd, II_CRC32W>;
828 class CRC32CB_DESC : CRC_DESC_BASE<"crc32cb", GPR32Opnd, II_CRC32CB>;
829 class CRC32CH_DESC : CRC_DESC_BASE<"crc32ch", GPR32Opnd, II_CRC32CH>;
830 class CRC32CW_DESC : CRC_DESC_BASE<"crc32cw", GPR32Opnd, II_CRC32CW>;
832 class GINV_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
833 InstrItinClass itin> : MipsR6Arch<instr_asm> {
834 dag OutOperandList = (outs);
835 dag InOperandList = (ins GPROpnd:$rs, uimm2:$type_);
836 string AsmString = !strconcat(instr_asm, "\t$rs, $type_");
837 list<dag> Pattern = [];
838 InstrItinClass Itinerary = itin;
839 bit hasSideEffects = 1;
842 class GINVI_DESC : GINV_DESC_BASE<"ginvi", GPR32Opnd, II_GINVI> {
843 dag InOperandList = (ins GPR32Opnd:$rs);
844 string AsmString = "ginvi\t$rs";
846 class GINVT_DESC : GINV_DESC_BASE<"ginvt", GPR32Opnd, II_GINVT>;
849 dag OutOperandList = (outs);
850 dag InOperandList = (ins uimm16:$code_);
851 string AsmString = "sigrie\t$code_";
852 list<dag> Pattern = [];
853 InstrItinClass Itinerary = II_SIGRIE;
856 //===----------------------------------------------------------------------===//
858 // Instruction Definitions
860 //===----------------------------------------------------------------------===//
862 def ADDIUPC : R6MMR6Rel, ADDIUPC_ENC, ADDIUPC_DESC, ISA_MIPS32R6;
863 def ALIGN : R6MMR6Rel, ALIGN_ENC, ALIGN_DESC, ISA_MIPS32R6;
864 def ALUIPC : R6MMR6Rel, ALUIPC_ENC, ALUIPC_DESC, ISA_MIPS32R6;
865 def AUI : R6MMR6Rel, AUI_ENC, AUI_DESC, ISA_MIPS32R6;
866 def AUIPC : R6MMR6Rel, AUIPC_ENC, AUIPC_DESC, ISA_MIPS32R6;
867 def BAL : BAL_ENC, BAL_DESC, ISA_MIPS32R6;
868 def BALC : R6MMR6Rel, BALC_ENC, BALC_DESC, ISA_MIPS32R6;
869 let AdditionalPredicates = [NotInMicroMips] in {
870 def BC1EQZ : BC1EQZ_ENC, BC1EQZ_DESC, ISA_MIPS32R6, HARDFLOAT;
871 def BC1NEZ : BC1NEZ_ENC, BC1NEZ_DESC, ISA_MIPS32R6, HARDFLOAT;
872 def BC2EQZ : BC2EQZ_ENC, BC2EQZ_DESC, ISA_MIPS32R6;
873 def BC2NEZ : BC2NEZ_ENC, BC2NEZ_DESC, ISA_MIPS32R6;
874 def BC : R6MMR6Rel, BC_ENC, BC_DESC, ISA_MIPS32R6;
875 def BEQC : R6MMR6Rel, BEQC_ENC, BEQC_DESC, ISA_MIPS32R6;
876 def BEQZALC : R6MMR6Rel, BEQZALC_ENC, BEQZALC_DESC, ISA_MIPS32R6;
877 def BEQZC : R6MMR6Rel, BEQZC_ENC, BEQZC_DESC, ISA_MIPS32R6;
878 def BGEC : R6MMR6Rel, BGEC_ENC, BGEC_DESC, ISA_MIPS32R6;
879 def BGEUC : R6MMR6Rel, BGEUC_ENC, BGEUC_DESC, ISA_MIPS32R6;
880 def BGEZALC : R6MMR6Rel, BGEZALC_ENC, BGEZALC_DESC, ISA_MIPS32R6;
881 def BGEZC : R6MMR6Rel, BGEZC_ENC, BGEZC_DESC, ISA_MIPS32R6;
882 def BGTZALC : R6MMR6Rel, BGTZALC_ENC, BGTZALC_DESC, ISA_MIPS32R6;
883 def BGTZC : R6MMR6Rel, BGTZC_ENC, BGTZC_DESC, ISA_MIPS32R6;
885 def BITSWAP : R6MMR6Rel, BITSWAP_ENC, BITSWAP_DESC, ISA_MIPS32R6;
886 let AdditionalPredicates = [NotInMicroMips] in {
887 def BLEZALC : R6MMR6Rel, BLEZALC_ENC, BLEZALC_DESC, ISA_MIPS32R6;
888 def BLEZC : R6MMR6Rel, BLEZC_ENC, BLEZC_DESC, ISA_MIPS32R6;
889 def BLTC : R6MMR6Rel, BLTC_ENC, BLTC_DESC, ISA_MIPS32R6;
890 def BLTUC : R6MMR6Rel, BLTUC_ENC, BLTUC_DESC, ISA_MIPS32R6;
891 def BLTZALC : R6MMR6Rel, BLTZALC_ENC, BLTZALC_DESC, ISA_MIPS32R6;
892 def BLTZC : R6MMR6Rel, BLTZC_ENC, BLTZC_DESC, ISA_MIPS32R6;
893 def BNEC : R6MMR6Rel, BNEC_ENC, BNEC_DESC, ISA_MIPS32R6;
894 def BNEZALC : R6MMR6Rel, BNEZALC_ENC, BNEZALC_DESC, ISA_MIPS32R6;
895 def BNEZC : R6MMR6Rel, BNEZC_ENC, BNEZC_DESC, ISA_MIPS32R6;
896 def BNVC : R6MMR6Rel, BNVC_ENC, BNVC_DESC, ISA_MIPS32R6;
897 def BOVC : R6MMR6Rel, BOVC_ENC, BOVC_DESC, ISA_MIPS32R6;
898 def CACHE_R6 : R6MMR6Rel, CACHE_ENC, CACHE_DESC, ISA_MIPS32R6;
899 def CLASS_D : CLASS_D_ENC, CLASS_D_DESC, ISA_MIPS32R6, HARDFLOAT;
900 def CLASS_S : CLASS_S_ENC, CLASS_S_DESC, ISA_MIPS32R6, HARDFLOAT;
902 def CLO_R6 : R6MMR6Rel, CLO_R6_ENC, CLO_R6_DESC, ISA_MIPS32R6;
903 def CLZ_R6 : R6MMR6Rel, CLZ_R6_ENC, CLZ_R6_DESC, ISA_MIPS32R6;
904 defm S : CMP_CC_M<FIELD_CMP_FORMAT_S, "s", FGR32Opnd, II_CMP_CC_S>;
905 defm D : CMP_CC_M<FIELD_CMP_FORMAT_D, "d", FGR64Opnd, II_CMP_CC_D>;
906 let AdditionalPredicates = [NotInMicroMips] in {
907 def DIV : R6MMR6Rel, DIV_ENC, DIV_DESC, ISA_MIPS32R6;
908 def DIVU : R6MMR6Rel, DIVU_ENC, DIVU_DESC, ISA_MIPS32R6;
911 def DVP : R6MMR6Rel, DVP_ENC, DVP_DESC, ISA_MIPS32R6;
912 def EVP : R6MMR6Rel, EVP_ENC, EVP_DESC, ISA_MIPS32R6;
914 def JIALC : R6MMR6Rel, JIALC_ENC, JIALC_DESC, ISA_MIPS32R6;
915 def JIC : R6MMR6Rel, JIC_ENC, JIC_DESC, ISA_MIPS32R6;
916 def JR_HB_R6 : JR_HB_R6_ENC, JR_HB_R6_DESC, ISA_MIPS32R6;
917 let AdditionalPredicates = [NotInMicroMips] in {
918 def LDC2_R6 : LDC2_R6_ENC, LDC2_R6_DESC, ISA_MIPS32R6;
919 def LL_R6 : LL_R6_ENC, LL_R6_DESC, PTR_32, ISA_MIPS32R6;
921 def LSA_R6 : R6MMR6Rel, LSA_R6_ENC, LSA_R6_DESC, ISA_MIPS32R6;
922 let AdditionalPredicates = [NotInMicroMips] in {
923 def LWC2_R6 : LWC2_R6_ENC, LWC2_R6_DESC, ISA_MIPS32R6;
925 def LWPC : R6MMR6Rel, LWPC_ENC, LWPC_DESC, ISA_MIPS32R6;
926 let AdditionalPredicates = [NotInMicroMips] in {
927 def MADDF_S : MADDF_S_ENC, MADDF_S_DESC, ISA_MIPS32R6, HARDFLOAT;
928 def MADDF_D : MADDF_D_ENC, MADDF_D_DESC, ISA_MIPS32R6, HARDFLOAT;
929 def MAXA_D : MAXA_D_ENC, MAXA_D_DESC, ISA_MIPS32R6, HARDFLOAT;
930 def MAXA_S : MAXA_S_ENC, MAXA_S_DESC, ISA_MIPS32R6, HARDFLOAT;
931 def MAX_D : MAX_D_ENC, MAX_D_DESC, ISA_MIPS32R6, HARDFLOAT;
932 def MAX_S : MAX_S_ENC, MAX_S_DESC, ISA_MIPS32R6, HARDFLOAT;
933 def MINA_D : MINA_D_ENC, MINA_D_DESC, ISA_MIPS32R6, HARDFLOAT;
934 def MINA_S : MINA_S_ENC, MINA_S_DESC, ISA_MIPS32R6, HARDFLOAT;
935 def MIN_D : MIN_D_ENC, MIN_D_DESC, ISA_MIPS32R6, HARDFLOAT;
936 def MIN_S : MIN_S_ENC, MIN_S_DESC, ISA_MIPS32R6, HARDFLOAT;
938 def MOD : R6MMR6Rel, MOD_ENC, MOD_DESC, ISA_MIPS32R6;
939 def MODU : R6MMR6Rel, MODU_ENC, MODU_DESC, ISA_MIPS32R6;
941 def MSUBF_S : MSUBF_S_ENC, MSUBF_S_DESC, ISA_MIPS32R6, HARDFLOAT;
942 def MSUBF_D : MSUBF_D_ENC, MSUBF_D_DESC, ISA_MIPS32R6, HARDFLOAT;
944 def MUH : R6MMR6Rel, MUH_ENC, MUH_DESC, ISA_MIPS32R6;
945 def MUHU : R6MMR6Rel, MUHU_ENC, MUHU_DESC, ISA_MIPS32R6;
946 def MUL_R6 : R6MMR6Rel, MUL_R6_ENC, MUL_R6_DESC, ISA_MIPS32R6;
947 def MULU : R6MMR6Rel, MULU_ENC, MULU_DESC, ISA_MIPS32R6;
949 def NAL; // BAL with rd=0
950 let AdditionalPredicates = [NotInMicroMips] in {
951 def PREF_R6 : R6MMR6Rel, PREF_ENC, PREF_DESC, ISA_MIPS32R6;
952 def RINT_D : RINT_D_ENC, RINT_D_DESC, ISA_MIPS32R6, HARDFLOAT;
953 def RINT_S : RINT_S_ENC, RINT_S_DESC, ISA_MIPS32R6, HARDFLOAT;
954 def SC_R6 : SC_R6_ENC, SC_R6_DESC, PTR_32, ISA_MIPS32R6;
955 def SDBBP_R6 : SDBBP_R6_ENC, SDBBP_R6_DESC, ISA_MIPS32R6;
956 def SELEQZ : R6MMR6Rel, SELEQZ_ENC, SELEQZ_DESC, ISA_MIPS32R6, GPR_32;
957 def SELNEZ : R6MMR6Rel, SELNEZ_ENC, SELNEZ_DESC, ISA_MIPS32R6, GPR_32;
958 def SELEQZ_D : R6MMR6Rel, SELEQZ_D_ENC, SELEQZ_D_DESC, ISA_MIPS32R6,
960 def SELEQZ_S : R6MMR6Rel, SELEQZ_S_ENC, SELEQZ_S_DESC, ISA_MIPS32R6,
962 def SELNEZ_D : R6MMR6Rel, SELNEZ_D_ENC, SELNEZ_D_DESC, ISA_MIPS32R6,
964 def SELNEZ_S : R6MMR6Rel, SELNEZ_S_ENC, SELNEZ_S_DESC, ISA_MIPS32R6,
966 def SEL_D : R6MMR6Rel, SEL_D_ENC, SEL_D_DESC, ISA_MIPS32R6, HARDFLOAT;
967 def SEL_S : R6MMR6Rel, SEL_S_ENC, SEL_S_DESC, ISA_MIPS32R6, HARDFLOAT;
968 def SDC2_R6 : SDC2_R6_ENC, SDC2_R6_DESC, ISA_MIPS32R6;
969 def SWC2_R6 : SWC2_R6_ENC, SWC2_R6_DESC, ISA_MIPS32R6;
970 def SIGRIE : SIGRIE_ENC, SIGRIE_DESC, ISA_MIPS32R6;
973 let AdditionalPredicates = [NotInMicroMips] in {
974 def CRC32B : R6MMR6Rel, CRC32B_ENC, CRC32B_DESC, ISA_MIPS32R6, ASE_CRC;
975 def CRC32H : R6MMR6Rel, CRC32H_ENC, CRC32H_DESC, ISA_MIPS32R6, ASE_CRC;
976 def CRC32W : R6MMR6Rel, CRC32W_ENC, CRC32W_DESC, ISA_MIPS32R6, ASE_CRC;
977 def CRC32CB : R6MMR6Rel, CRC32CB_ENC, CRC32CB_DESC, ISA_MIPS32R6, ASE_CRC;
978 def CRC32CH : R6MMR6Rel, CRC32CH_ENC, CRC32CH_DESC, ISA_MIPS32R6, ASE_CRC;
979 def CRC32CW : R6MMR6Rel, CRC32CW_ENC, CRC32CW_DESC, ISA_MIPS32R6, ASE_CRC;
982 let AdditionalPredicates = [NotInMicroMips] in {
983 def GINVI : R6MMR6Rel, GINVI_ENC, GINVI_DESC, ISA_MIPS32R6, ASE_GINV;
984 def GINVT : R6MMR6Rel, GINVT_ENC, GINVT_DESC, ISA_MIPS32R6, ASE_GINV;
987 //===----------------------------------------------------------------------===//
989 // Instruction Aliases
991 //===----------------------------------------------------------------------===//
993 def : MipsInstAlias<"dvp", (DVP ZERO), 0>, ISA_MIPS32R6;
994 def : MipsInstAlias<"evp", (EVP ZERO), 0>, ISA_MIPS32R6;
996 let AdditionalPredicates = [NotInMicroMips] in {
997 def : MipsInstAlias<"sdbbp", (SDBBP_R6 0)>, ISA_MIPS32R6;
998 def : MipsInstAlias<"sigrie", (SIGRIE 0)>, ISA_MIPS32R6;
999 def : MipsInstAlias<"jr $rs", (JALR ZERO, GPR32Opnd:$rs), 1>, ISA_MIPS32R6, GPR_32;
1002 def : MipsInstAlias<"jrc $rs", (JIC GPR32Opnd:$rs, 0), 1>, ISA_MIPS32R6, GPR_32;
1004 let AdditionalPredicates = [NotInMicroMips] in {
1005 def : MipsInstAlias<"jalrc $rs", (JIALC GPR32Opnd:$rs, 0), 1>, ISA_MIPS32R6, GPR_32;
1008 def : MipsInstAlias<"div $rs, $rt", (DIV GPR32Opnd:$rs, GPR32Opnd:$rs,
1009 GPR32Opnd:$rt)>, ISA_MIPS32R6;
1010 def : MipsInstAlias<"divu $rs, $rt", (DIVU GPR32Opnd:$rs, GPR32Opnd:$rs,
1011 GPR32Opnd:$rt)>, ISA_MIPS32R6;
1013 def : MipsInstAlias<"lapc $rd, $imm",
1014 (ADDIUPC GPR32Opnd:$rd, simm19_lsl2:$imm)>, ISA_MIPS32R6;
1016 //===----------------------------------------------------------------------===//
1018 // Patterns and Pseudo Instructions
1020 //===----------------------------------------------------------------------===//
1022 // comparisons supported via another comparison
1023 multiclass Cmp_Pats<ValueType VT, Instruction NOROp, Register ZEROReg> {
1024 def : MipsPat<(setone VT:$lhs, VT:$rhs),
1025 (NOROp (!cast<Instruction>("CMP_UEQ_"#NAME) VT:$lhs, VT:$rhs), ZEROReg)>;
1026 def : MipsPat<(seto VT:$lhs, VT:$rhs),
1027 (NOROp (!cast<Instruction>("CMP_UN_"#NAME) VT:$lhs, VT:$rhs), ZEROReg)>;
1028 def : MipsPat<(setune VT:$lhs, VT:$rhs),
1029 (NOROp (!cast<Instruction>("CMP_EQ_"#NAME) VT:$lhs, VT:$rhs), ZEROReg)>;
1030 def : MipsPat<(seteq VT:$lhs, VT:$rhs),
1031 (!cast<Instruction>("CMP_EQ_"#NAME) VT:$lhs, VT:$rhs)>;
1032 def : MipsPat<(setgt VT:$lhs, VT:$rhs),
1033 (!cast<Instruction>("CMP_LE_"#NAME) VT:$rhs, VT:$lhs)>;
1034 def : MipsPat<(setge VT:$lhs, VT:$rhs),
1035 (!cast<Instruction>("CMP_LT_"#NAME) VT:$rhs, VT:$lhs)>;
1036 def : MipsPat<(setlt VT:$lhs, VT:$rhs),
1037 (!cast<Instruction>("CMP_LT_"#NAME) VT:$lhs, VT:$rhs)>;
1038 def : MipsPat<(setle VT:$lhs, VT:$rhs),
1039 (!cast<Instruction>("CMP_LE_"#NAME) VT:$lhs, VT:$rhs)>;
1040 def : MipsPat<(setne VT:$lhs, VT:$rhs),
1041 (NOROp (!cast<Instruction>("CMP_EQ_"#NAME) VT:$lhs, VT:$rhs), ZEROReg)>;
1044 let AdditionalPredicates = [NotInMicroMips] in {
1045 defm S : Cmp_Pats<f32, NOR, ZERO>, ISA_MIPS32R6;
1046 defm D : Cmp_Pats<f64, NOR, ZERO>, ISA_MIPS32R6;
1050 multiclass SelectInt_Pats<ValueType RC, Instruction OROp, Instruction XORiOp,
1051 Instruction SLTiOp, Instruction SLTiuOp,
1052 Instruction SELEQZOp, Instruction SELNEZOp,
1053 SDPatternOperator imm_type, ValueType Opg> {
1055 def : MipsPat<(select (Opg (seteq RC:$cond, immz)), RC:$t, RC:$f),
1056 (OROp (SELEQZOp RC:$t, RC:$cond), (SELNEZOp RC:$f, RC:$cond))>;
1057 def : MipsPat<(select (Opg (setne RC:$cond, immz)), RC:$t, RC:$f),
1058 (OROp (SELNEZOp RC:$t, RC:$cond), (SELEQZOp RC:$f, RC:$cond))>;
1060 // reg, immZExt16[_64]
1061 def : MipsPat<(select (Opg (seteq RC:$cond, imm_type:$imm)), RC:$t, RC:$f),
1062 (OROp (SELEQZOp RC:$t, (XORiOp RC:$cond, imm_type:$imm)),
1063 (SELNEZOp RC:$f, (XORiOp RC:$cond, imm_type:$imm)))>;
1064 def : MipsPat<(select (Opg (setne RC:$cond, imm_type:$imm)), RC:$t, RC:$f),
1065 (OROp (SELNEZOp RC:$t, (XORiOp RC:$cond, imm_type:$imm)),
1066 (SELEQZOp RC:$f, (XORiOp RC:$cond, imm_type:$imm)))>;
1068 // reg, immSExt16Plus1
1069 def : MipsPat<(select (Opg (setgt RC:$cond, immSExt16Plus1:$imm)), RC:$t, RC:$f),
1070 (OROp (SELEQZOp RC:$t, (SLTiOp RC:$cond, (Plus1 imm:$imm))),
1071 (SELNEZOp RC:$f, (SLTiOp RC:$cond, (Plus1 imm:$imm))))>;
1072 def : MipsPat<(select (Opg (setugt RC:$cond, immSExt16Plus1:$imm)), RC:$t, RC:$f),
1073 (OROp (SELEQZOp RC:$t, (SLTiuOp RC:$cond, (Plus1 imm:$imm))),
1074 (SELNEZOp RC:$f, (SLTiuOp RC:$cond, (Plus1 imm:$imm))))>;
1076 def : MipsPat<(select (Opg (seteq RC:$cond, immz)), RC:$t, immz),
1077 (SELEQZOp RC:$t, RC:$cond)>;
1078 def : MipsPat<(select (Opg (setne RC:$cond, immz)), RC:$t, immz),
1079 (SELNEZOp RC:$t, RC:$cond)>;
1080 def : MipsPat<(select (Opg (seteq RC:$cond, immz)), immz, RC:$f),
1081 (SELNEZOp RC:$f, RC:$cond)>;
1082 def : MipsPat<(select (Opg (setne RC:$cond, immz)), immz, RC:$f),
1083 (SELEQZOp RC:$f, RC:$cond)>;
1086 let AdditionalPredicates = [NotInMicroMips] in {
1087 defm : SelectInt_Pats<i32, OR, XORi, SLTi, SLTiu, SELEQZ, SELNEZ,
1088 immZExt16, i32>, ISA_MIPS32R6;
1090 def : MipsPat<(select i32:$cond, i32:$t, i32:$f),
1091 (OR (SELNEZ i32:$t, i32:$cond),
1092 (SELEQZ i32:$f, i32:$cond))>,
1094 def : MipsPat<(select i32:$cond, i32:$t, immz),
1095 (SELNEZ i32:$t, i32:$cond)>,
1097 def : MipsPat<(select i32:$cond, immz, i32:$f),
1098 (SELEQZ i32:$f, i32:$cond)>,
1102 // Pseudo instructions
1103 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, hasDelaySlot = 1,
1104 hasExtraSrcRegAllocReq = 1, isCTI = 1, Defs = [AT], hasPostISelHook = 1 in {
1105 class TailCallRegR6<Instruction JumpInst, Register RT, RegisterOperand RO> :
1106 PseudoSE<(outs), (ins RO:$rs), [(MipsTailCall RO:$rs)], II_JR>,
1107 PseudoInstExpansion<(JumpInst RT:$rt, RO:$rs)>;
1110 class PseudoIndirectBranchBaseR6<Instruction JumpInst, Register RT,
1111 RegisterOperand RO> :
1112 MipsPseudo<(outs), (ins RO:$rs), [(brind RO:$rs)],
1113 II_IndirectBranchPseudo>,
1114 PseudoInstExpansion<(JumpInst RT:$rt, RO:$rs)> {
1117 let hasDelaySlot = 1;
1119 let isIndirectBranch = 1;
1124 let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips,
1125 NoIndirectJumpGuards] in {
1126 def TAILCALLR6REG : TailCallRegR6<JALR, ZERO, GPR32Opnd>, ISA_MIPS32R6;
1127 def PseudoIndirectBranchR6 : PseudoIndirectBranchBaseR6<JALR, ZERO,
1132 let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips,
1133 UseIndirectJumpsHazard] in {
1134 def TAILCALLHBR6REG : TailCallReg<JR_HB_R6, GPR32Opnd>, ISA_MIPS32R6;
1135 def PseudoIndrectHazardBranchR6 : PseudoIndirectBranchBase<JR_HB_R6,