1 //===- MipsDSPInstrFormats.td - Mips Instruction Formats ---*- 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 //===----------------------------------------------------------------------===//
11 def Dsp2MicroMips : InstrMapping {
12 let FilterClass = "DspMMRel";
13 // Instructions with the same BaseOpcode and isNVStore values form a row.
14 let RowFields = ["BaseOpcode"];
15 // Instructions with the same predicate sense form a column.
16 let ColFields = ["Arch"];
17 // The key column is the unpredicated instructions.
19 // Value columns are PredSense=true and PredSense=false
20 let ValueCols = [["dsp"], ["mmdsp"]];
23 def HasDSP : Predicate<"Subtarget->hasDSP()">,
24 AssemblerPredicate<"FeatureDSP">;
25 def HasDSPR2 : Predicate<"Subtarget->hasDSPR2()">,
26 AssemblerPredicate<"FeatureDSPR2">;
27 def HasDSPR3 : Predicate<"Subtarget->hasDSPR3()">,
28 AssemblerPredicate<"FeatureDSPR3">;
31 list<Predicate> ASEPredicate = [HasDSPR2];
35 list<Predicate> ASEPredicate = [HasDSPR3];
39 class Field6<bits<6> val> {
43 def SPECIAL3_OPCODE : Field6<0b011111>;
44 def REGIMM_OPCODE : Field6<0b000001>;
46 class DSPInst<string opstr = "">
47 : MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther> {
48 let ASEPredicate = [HasDSP];
49 string BaseOpcode = opstr;
53 class PseudoDSP<dag outs, dag ins, list<dag> pattern,
54 InstrItinClass itin = IIPseudo>
55 : MipsPseudo<outs, ins, pattern, itin> {
56 let ASEPredicate = [HasDSP];
59 class DSPInstAlias<string Asm, dag Result, bit Emit = 0b1>
60 : InstAlias<Asm, Result, Emit>, PredicateControl {
61 let ASEPredicate = [HasDSP];
64 // ADDU.QB sub-class format.
65 class ADDU_QB_FMT<bits<5> op> : DSPInst {
70 let Opcode = SPECIAL3_OPCODE.V;
76 let Inst{5-0} = 0b010000;
79 class RADDU_W_QB_FMT<bits<5> op> : DSPInst {
83 let Opcode = SPECIAL3_OPCODE.V;
89 let Inst{5-0} = 0b010000;
92 // CMPU.EQ.QB sub-class format.
93 class CMP_EQ_QB_R2_FMT<bits<5> op> : DSPInst {
97 let Opcode = SPECIAL3_OPCODE.V;
100 let Inst{20-16} = rt;
103 let Inst{5-0} = 0b010001;
106 class CMP_EQ_QB_R3_FMT<bits<5> op> : DSPInst {
111 let Opcode = SPECIAL3_OPCODE.V;
113 let Inst{25-21} = rs;
114 let Inst{20-16} = rt;
115 let Inst{15-11} = rd;
117 let Inst{5-0} = 0b010001;
120 class PRECR_SRA_PH_W_FMT<bits<5> op> : DSPInst {
125 let Opcode = SPECIAL3_OPCODE.V;
127 let Inst{25-21} = rs;
128 let Inst{20-16} = rt;
129 let Inst{15-11} = sa;
131 let Inst{5-0} = 0b010001;
134 // ABSQ_S.PH sub-class format.
135 class ABSQ_S_PH_R2_FMT<bits<5> op> : DSPInst {
139 let Opcode = SPECIAL3_OPCODE.V;
142 let Inst{20-16} = rt;
143 let Inst{15-11} = rd;
145 let Inst{5-0} = 0b010010;
149 class REPL_FMT<bits<5> op> : DSPInst {
153 let Opcode = SPECIAL3_OPCODE.V;
155 let Inst{25-16} = imm;
156 let Inst{15-11} = rd;
158 let Inst{5-0} = 0b010010;
161 // SHLL.QB sub-class format.
162 class SHLL_QB_FMT<bits<5> op> : DSPInst {
167 let Opcode = SPECIAL3_OPCODE.V;
169 let Inst{25-21} = rs_sa;
170 let Inst{20-16} = rt;
171 let Inst{15-11} = rd;
173 let Inst{5-0} = 0b010011;
176 // LX sub-class format.
177 class LX_FMT<bits<5> op> : DSPInst {
182 let Opcode = SPECIAL3_OPCODE.V;
184 let Inst{25-21} = base;
185 let Inst{20-16} = index;
186 let Inst{15-11} = rd;
188 let Inst{5-0} = 0b001010;
191 // ADDUH.QB sub-class format.
192 class ADDUH_QB_FMT<bits<5> op> : DSPInst {
197 let Opcode = SPECIAL3_OPCODE.V;
199 let Inst{25-21} = rs;
200 let Inst{20-16} = rt;
201 let Inst{15-11} = rd;
203 let Inst{5-0} = 0b011000;
206 // APPEND sub-class format.
207 class APPEND_FMT<bits<5> op> : DSPInst {
212 let Opcode = SPECIAL3_OPCODE.V;
214 let Inst{25-21} = rs;
215 let Inst{20-16} = rt;
216 let Inst{15-11} = sa;
218 let Inst{5-0} = 0b110001;
221 // DPA.W.PH sub-class format.
222 class DPA_W_PH_FMT<bits<5> op> : DSPInst {
227 let Opcode = SPECIAL3_OPCODE.V;
229 let Inst{25-21} = rs;
230 let Inst{20-16} = rt;
232 let Inst{12-11} = ac;
234 let Inst{5-0} = 0b110000;
237 // MULT sub-class format.
238 class MULT_FMT<bits<6> opcode, bits<6> funct> : DSPInst {
245 let Inst{25-21} = rs;
246 let Inst{20-16} = rt;
248 let Inst{12-11} = ac;
250 let Inst{5-0} = funct;
253 // MFHI sub-class format.
254 class MFHI_FMT<bits<6> funct> : DSPInst {
260 let Inst{22-21} = ac;
262 let Inst{15-11} = rd;
264 let Inst{5-0} = funct;
267 // MTHI sub-class format.
268 class MTHI_FMT<bits<6> funct> : DSPInst {
273 let Inst{25-21} = rs;
275 let Inst{12-11} = ac;
277 let Inst{5-0} = funct;
280 // EXTR.W sub-class format (type 1).
281 class EXTR_W_TY1_FMT<bits<5> op> : DSPInst {
286 let Opcode = SPECIAL3_OPCODE.V;
288 let Inst{25-21} = shift_rs;
289 let Inst{20-16} = rt;
291 let Inst{12-11} = ac;
293 let Inst{5-0} = 0b111000;
296 // SHILO sub-class format.
297 class SHILO_R1_FMT<bits<5> op> : DSPInst {
301 let Opcode = SPECIAL3_OPCODE.V;
303 let Inst{25-20} = shift;
305 let Inst{12-11} = ac;
307 let Inst{5-0} = 0b111000;
310 class SHILO_R2_FMT<bits<5> op> : DSPInst {
314 let Opcode = SPECIAL3_OPCODE.V;
316 let Inst{25-21} = rs;
318 let Inst{12-11} = ac;
320 let Inst{5-0} = 0b111000;
323 class RDDSP_FMT<bits<5> op> : DSPInst {
327 let Opcode = SPECIAL3_OPCODE.V;
329 let Inst{25-16} = mask;
330 let Inst{15-11} = rd;
332 let Inst{5-0} = 0b111000;
335 class WRDSP_FMT<bits<5> op> : DSPInst {
339 let Opcode = SPECIAL3_OPCODE.V;
341 let Inst{25-21} = rs;
342 let Inst{20-11} = mask;
344 let Inst{5-0} = 0b111000;
347 class BPOSGE32_FMT<bits<5> op> : DSPInst {
350 let Opcode = REGIMM_OPCODE.V;
353 let Inst{20-16} = op;
354 let Inst{15-0} = offset;
357 // INSV sub-class format.
358 class INSV_FMT<bits<6> op> : DSPInst {
362 let Opcode = SPECIAL3_OPCODE.V;
364 let Inst{25-21} = rs;
365 let Inst{20-16} = rt;