• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===- MipsDSPInstrInfo.td - DSP ASE instructions -*- 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 Mips DSP ASE instructions.
11//
12//===----------------------------------------------------------------------===//
13
14// ImmLeaf
15def immZExt1 : ImmLeaf<i32, [{return isUInt<1>(Imm);}]>;
16def immZExt2 : ImmLeaf<i32, [{return isUInt<2>(Imm);}]>;
17def immZExt3 : ImmLeaf<i32, [{return isUInt<3>(Imm);}]>;
18def immZExt4 : ImmLeaf<i32, [{return isUInt<4>(Imm);}]>;
19def immZExt8 : ImmLeaf<i32, [{return isUInt<8>(Imm);}]>;
20def immZExt10 : ImmLeaf<i32, [{return isUInt<10>(Imm);}]>;
21def immSExt6 : ImmLeaf<i32, [{return isInt<6>(Imm);}]>;
22def immSExt10 : ImmLeaf<i32, [{return isInt<10>(Imm);}]>;
23
24// Mips-specific dsp nodes
25def SDT_MipsExtr : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisSameAs<0, 1>,
26                                        SDTCisVT<2, untyped>]>;
27def SDT_MipsShilo : SDTypeProfile<1, 2, [SDTCisVT<0, untyped>,
28                                         SDTCisSameAs<0, 2>, SDTCisVT<1, i32>]>;
29def SDT_MipsDPA : SDTypeProfile<1, 3, [SDTCisVT<0, untyped>, SDTCisSameAs<0, 3>,
30                                       SDTCisVT<1, i32>, SDTCisSameAs<1, 2>]>;
31def SDT_MipsSHIFT_DSP : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisSameAs<0, 1>,
32                                             SDTCisVT<2, i32>]>;
33
34class MipsDSPBase<string Opc, SDTypeProfile Prof> :
35  SDNode<!strconcat("MipsISD::", Opc), Prof>;
36
37class MipsDSPSideEffectBase<string Opc, SDTypeProfile Prof> :
38  SDNode<!strconcat("MipsISD::", Opc), Prof, [SDNPHasChain, SDNPSideEffect]>;
39
40def MipsEXTP : MipsDSPSideEffectBase<"EXTP", SDT_MipsExtr>;
41def MipsEXTPDP : MipsDSPSideEffectBase<"EXTPDP", SDT_MipsExtr>;
42def MipsEXTR_S_H : MipsDSPSideEffectBase<"EXTR_S_H", SDT_MipsExtr>;
43def MipsEXTR_W : MipsDSPSideEffectBase<"EXTR_W", SDT_MipsExtr>;
44def MipsEXTR_R_W : MipsDSPSideEffectBase<"EXTR_R_W", SDT_MipsExtr>;
45def MipsEXTR_RS_W : MipsDSPSideEffectBase<"EXTR_RS_W", SDT_MipsExtr>;
46
47def MipsSHILO : MipsDSPBase<"SHILO", SDT_MipsShilo>;
48def MipsMTHLIP : MipsDSPSideEffectBase<"MTHLIP", SDT_MipsShilo>;
49
50def MipsMULSAQ_S_W_PH : MipsDSPSideEffectBase<"MULSAQ_S_W_PH", SDT_MipsDPA>;
51def MipsMAQ_S_W_PHL : MipsDSPSideEffectBase<"MAQ_S_W_PHL", SDT_MipsDPA>;
52def MipsMAQ_S_W_PHR : MipsDSPSideEffectBase<"MAQ_S_W_PHR", SDT_MipsDPA>;
53def MipsMAQ_SA_W_PHL : MipsDSPSideEffectBase<"MAQ_SA_W_PHL", SDT_MipsDPA>;
54def MipsMAQ_SA_W_PHR : MipsDSPSideEffectBase<"MAQ_SA_W_PHR", SDT_MipsDPA>;
55
56def MipsDPAU_H_QBL : MipsDSPBase<"DPAU_H_QBL", SDT_MipsDPA>;
57def MipsDPAU_H_QBR : MipsDSPBase<"DPAU_H_QBR", SDT_MipsDPA>;
58def MipsDPSU_H_QBL : MipsDSPBase<"DPSU_H_QBL", SDT_MipsDPA>;
59def MipsDPSU_H_QBR : MipsDSPBase<"DPSU_H_QBR", SDT_MipsDPA>;
60def MipsDPAQ_S_W_PH : MipsDSPSideEffectBase<"DPAQ_S_W_PH", SDT_MipsDPA>;
61def MipsDPSQ_S_W_PH : MipsDSPSideEffectBase<"DPSQ_S_W_PH", SDT_MipsDPA>;
62def MipsDPAQ_SA_L_W : MipsDSPSideEffectBase<"DPAQ_SA_L_W", SDT_MipsDPA>;
63def MipsDPSQ_SA_L_W : MipsDSPSideEffectBase<"DPSQ_SA_L_W", SDT_MipsDPA>;
64
65def MipsDPA_W_PH : MipsDSPBase<"DPA_W_PH", SDT_MipsDPA>;
66def MipsDPS_W_PH : MipsDSPBase<"DPS_W_PH", SDT_MipsDPA>;
67def MipsDPAQX_S_W_PH : MipsDSPSideEffectBase<"DPAQX_S_W_PH", SDT_MipsDPA>;
68def MipsDPAQX_SA_W_PH : MipsDSPSideEffectBase<"DPAQX_SA_W_PH", SDT_MipsDPA>;
69def MipsDPAX_W_PH : MipsDSPBase<"DPAX_W_PH", SDT_MipsDPA>;
70def MipsDPSX_W_PH : MipsDSPBase<"DPSX_W_PH", SDT_MipsDPA>;
71def MipsDPSQX_S_W_PH : MipsDSPSideEffectBase<"DPSQX_S_W_PH", SDT_MipsDPA>;
72def MipsDPSQX_SA_W_PH : MipsDSPSideEffectBase<"DPSQX_SA_W_PH", SDT_MipsDPA>;
73def MipsMULSA_W_PH : MipsDSPBase<"MULSA_W_PH", SDT_MipsDPA>;
74
75def MipsMULT : MipsDSPBase<"MULT", SDT_MipsDPA>;
76def MipsMULTU : MipsDSPBase<"MULTU", SDT_MipsDPA>;
77def MipsMADD_DSP : MipsDSPBase<"MADD_DSP", SDT_MipsDPA>;
78def MipsMADDU_DSP : MipsDSPBase<"MADDU_DSP", SDT_MipsDPA>;
79def MipsMSUB_DSP : MipsDSPBase<"MSUB_DSP", SDT_MipsDPA>;
80def MipsMSUBU_DSP : MipsDSPBase<"MSUBU_DSP", SDT_MipsDPA>;
81def MipsSHLL_DSP : MipsDSPBase<"SHLL_DSP", SDT_MipsSHIFT_DSP>;
82def MipsSHRA_DSP : MipsDSPBase<"SHRA_DSP", SDT_MipsSHIFT_DSP>;
83def MipsSHRL_DSP : MipsDSPBase<"SHRL_DSP", SDT_MipsSHIFT_DSP>;
84def MipsSETCC_DSP : MipsDSPBase<"SETCC_DSP", SDTSetCC>;
85def MipsSELECT_CC_DSP : MipsDSPBase<"SELECT_CC_DSP", SDTSelectCC>;
86
87// Flags.
88class Uses<list<Register> Regs> {
89  list<Register> Uses = Regs;
90}
91
92class Defs<list<Register> Regs> {
93  list<Register> Defs = Regs;
94}
95
96// Instruction encoding.
97class ADDU_QB_ENC : ADDU_QB_FMT<0b00000>;
98class ADDU_S_QB_ENC : ADDU_QB_FMT<0b00100>;
99class SUBU_QB_ENC : ADDU_QB_FMT<0b00001>;
100class SUBU_S_QB_ENC : ADDU_QB_FMT<0b00101>;
101class ADDQ_PH_ENC : ADDU_QB_FMT<0b01010>;
102class ADDQ_S_PH_ENC : ADDU_QB_FMT<0b01110>;
103class SUBQ_PH_ENC : ADDU_QB_FMT<0b01011>;
104class SUBQ_S_PH_ENC : ADDU_QB_FMT<0b01111>;
105class ADDQ_S_W_ENC : ADDU_QB_FMT<0b10110>;
106class SUBQ_S_W_ENC : ADDU_QB_FMT<0b10111>;
107class ADDSC_ENC : ADDU_QB_FMT<0b10000>;
108class ADDWC_ENC : ADDU_QB_FMT<0b10001>;
109class MODSUB_ENC : ADDU_QB_FMT<0b10010>;
110class RADDU_W_QB_ENC : RADDU_W_QB_FMT<0b10100>;
111class ABSQ_S_PH_ENC : ABSQ_S_PH_R2_FMT<0b01001>;
112class ABSQ_S_W_ENC : ABSQ_S_PH_R2_FMT<0b10001>;
113class PRECRQ_QB_PH_ENC : CMP_EQ_QB_R3_FMT<0b01100>;
114class PRECRQ_PH_W_ENC : CMP_EQ_QB_R3_FMT<0b10100>;
115class PRECRQ_RS_PH_W_ENC : CMP_EQ_QB_R3_FMT<0b10101>;
116class PRECRQU_S_QB_PH_ENC : CMP_EQ_QB_R3_FMT<0b01111>;
117class PRECEQ_W_PHL_ENC : ABSQ_S_PH_R2_FMT<0b01100>;
118class PRECEQ_W_PHR_ENC : ABSQ_S_PH_R2_FMT<0b01101>;
119class PRECEQU_PH_QBL_ENC : ABSQ_S_PH_R2_FMT<0b00100>;
120class PRECEQU_PH_QBR_ENC : ABSQ_S_PH_R2_FMT<0b00101>;
121class PRECEQU_PH_QBLA_ENC : ABSQ_S_PH_R2_FMT<0b00110>;
122class PRECEQU_PH_QBRA_ENC : ABSQ_S_PH_R2_FMT<0b00111>;
123class PRECEU_PH_QBL_ENC : ABSQ_S_PH_R2_FMT<0b11100>;
124class PRECEU_PH_QBR_ENC : ABSQ_S_PH_R2_FMT<0b11101>;
125class PRECEU_PH_QBLA_ENC : ABSQ_S_PH_R2_FMT<0b11110>;
126class PRECEU_PH_QBRA_ENC : ABSQ_S_PH_R2_FMT<0b11111>;
127class SHLL_QB_ENC : SHLL_QB_FMT<0b00000>;
128class SHLLV_QB_ENC : SHLL_QB_FMT<0b00010>;
129class SHRL_QB_ENC : SHLL_QB_FMT<0b00001>;
130class SHRLV_QB_ENC : SHLL_QB_FMT<0b00011>;
131class SHLL_PH_ENC : SHLL_QB_FMT<0b01000>;
132class SHLLV_PH_ENC : SHLL_QB_FMT<0b01010>;
133class SHLL_S_PH_ENC : SHLL_QB_FMT<0b01100>;
134class SHLLV_S_PH_ENC : SHLL_QB_FMT<0b01110>;
135class SHRA_PH_ENC : SHLL_QB_FMT<0b01001>;
136class SHRAV_PH_ENC : SHLL_QB_FMT<0b01011>;
137class SHRA_R_PH_ENC : SHLL_QB_FMT<0b01101>;
138class SHRAV_R_PH_ENC : SHLL_QB_FMT<0b01111>;
139class SHLL_S_W_ENC : SHLL_QB_FMT<0b10100>;
140class SHLLV_S_W_ENC : SHLL_QB_FMT<0b10110>;
141class SHRA_R_W_ENC : SHLL_QB_FMT<0b10101>;
142class SHRAV_R_W_ENC : SHLL_QB_FMT<0b10111>;
143class MULEU_S_PH_QBL_ENC : ADDU_QB_FMT<0b00110>;
144class MULEU_S_PH_QBR_ENC : ADDU_QB_FMT<0b00111>;
145class MULEQ_S_W_PHL_ENC : ADDU_QB_FMT<0b11100>;
146class MULEQ_S_W_PHR_ENC : ADDU_QB_FMT<0b11101>;
147class MULQ_RS_PH_ENC : ADDU_QB_FMT<0b11111>;
148class MULSAQ_S_W_PH_ENC : DPA_W_PH_FMT<0b00110>;
149class MAQ_S_W_PHL_ENC : DPA_W_PH_FMT<0b10100>;
150class MAQ_S_W_PHR_ENC : DPA_W_PH_FMT<0b10110>;
151class MAQ_SA_W_PHL_ENC : DPA_W_PH_FMT<0b10000>;
152class MAQ_SA_W_PHR_ENC : DPA_W_PH_FMT<0b10010>;
153class MFHI_ENC : MFHI_FMT<0b010000>;
154class MFLO_ENC : MFHI_FMT<0b010010>;
155class MTHI_ENC : MTHI_FMT<0b010001>;
156class MTLO_ENC : MTHI_FMT<0b010011>;
157class DPAU_H_QBL_ENC : DPA_W_PH_FMT<0b00011>;
158class DPAU_H_QBR_ENC : DPA_W_PH_FMT<0b00111>;
159class DPSU_H_QBL_ENC : DPA_W_PH_FMT<0b01011>;
160class DPSU_H_QBR_ENC : DPA_W_PH_FMT<0b01111>;
161class DPAQ_S_W_PH_ENC : DPA_W_PH_FMT<0b00100>;
162class DPSQ_S_W_PH_ENC : DPA_W_PH_FMT<0b00101>;
163class DPAQ_SA_L_W_ENC : DPA_W_PH_FMT<0b01100>;
164class DPSQ_SA_L_W_ENC : DPA_W_PH_FMT<0b01101>;
165class MULT_DSP_ENC : MULT_FMT<0b000000, 0b011000>;
166class MULTU_DSP_ENC : MULT_FMT<0b000000, 0b011001>;
167class MADD_DSP_ENC : MULT_FMT<0b011100, 0b000000>;
168class MADDU_DSP_ENC : MULT_FMT<0b011100, 0b000001>;
169class MSUB_DSP_ENC : MULT_FMT<0b011100, 0b000100>;
170class MSUBU_DSP_ENC : MULT_FMT<0b011100, 0b000101>;
171class CMPU_EQ_QB_ENC : CMP_EQ_QB_R2_FMT<0b00000>;
172class CMPU_LT_QB_ENC : CMP_EQ_QB_R2_FMT<0b00001>;
173class CMPU_LE_QB_ENC : CMP_EQ_QB_R2_FMT<0b00010>;
174class CMPGU_EQ_QB_ENC : CMP_EQ_QB_R3_FMT<0b00100>;
175class CMPGU_LT_QB_ENC : CMP_EQ_QB_R3_FMT<0b00101>;
176class CMPGU_LE_QB_ENC : CMP_EQ_QB_R3_FMT<0b00110>;
177class CMP_EQ_PH_ENC : CMP_EQ_QB_R2_FMT<0b01000>;
178class CMP_LT_PH_ENC : CMP_EQ_QB_R2_FMT<0b01001>;
179class CMP_LE_PH_ENC : CMP_EQ_QB_R2_FMT<0b01010>;
180class BITREV_ENC : ABSQ_S_PH_R2_FMT<0b11011>;
181class PACKRL_PH_ENC : CMP_EQ_QB_R3_FMT<0b01110>;
182class REPL_QB_ENC : REPL_FMT<0b00010>;
183class REPL_PH_ENC : REPL_FMT<0b01010>;
184class REPLV_QB_ENC : ABSQ_S_PH_R2_FMT<0b00011>;
185class REPLV_PH_ENC : ABSQ_S_PH_R2_FMT<0b01011>;
186class PICK_QB_ENC : CMP_EQ_QB_R3_FMT<0b00011>;
187class PICK_PH_ENC : CMP_EQ_QB_R3_FMT<0b01011>;
188class LWX_ENC : LX_FMT<0b00000>;
189class LHX_ENC : LX_FMT<0b00100>;
190class LBUX_ENC : LX_FMT<0b00110>;
191class BPOSGE32_ENC : BPOSGE32_FMT<0b11100>;
192class INSV_ENC : INSV_FMT<0b001100>;
193
194class EXTP_ENC : EXTR_W_TY1_FMT<0b00010>;
195class EXTPV_ENC : EXTR_W_TY1_FMT<0b00011>;
196class EXTPDP_ENC : EXTR_W_TY1_FMT<0b01010>;
197class EXTPDPV_ENC : EXTR_W_TY1_FMT<0b01011>;
198class EXTR_W_ENC : EXTR_W_TY1_FMT<0b00000>;
199class EXTRV_W_ENC : EXTR_W_TY1_FMT<0b00001>;
200class EXTR_R_W_ENC : EXTR_W_TY1_FMT<0b00100>;
201class EXTRV_R_W_ENC : EXTR_W_TY1_FMT<0b00101>;
202class EXTR_RS_W_ENC : EXTR_W_TY1_FMT<0b00110>;
203class EXTRV_RS_W_ENC : EXTR_W_TY1_FMT<0b00111>;
204class EXTR_S_H_ENC : EXTR_W_TY1_FMT<0b01110>;
205class EXTRV_S_H_ENC : EXTR_W_TY1_FMT<0b01111>;
206class SHILO_ENC : SHILO_R1_FMT<0b11010>;
207class SHILOV_ENC : SHILO_R2_FMT<0b11011>;
208class MTHLIP_ENC : SHILO_R2_FMT<0b11111>;
209
210class RDDSP_ENC : RDDSP_FMT<0b10010>;
211class WRDSP_ENC : WRDSP_FMT<0b10011>;
212class ADDU_PH_ENC : ADDU_QB_FMT<0b01000>;
213class ADDU_S_PH_ENC : ADDU_QB_FMT<0b01100>;
214class SUBU_PH_ENC : ADDU_QB_FMT<0b01001>;
215class SUBU_S_PH_ENC : ADDU_QB_FMT<0b01101>;
216class CMPGDU_EQ_QB_ENC : CMP_EQ_QB_R3_FMT<0b11000>;
217class CMPGDU_LT_QB_ENC : CMP_EQ_QB_R3_FMT<0b11001>;
218class CMPGDU_LE_QB_ENC : CMP_EQ_QB_R3_FMT<0b11010>;
219class ABSQ_S_QB_ENC : ABSQ_S_PH_R2_FMT<0b00001>;
220class ADDUH_QB_ENC : ADDUH_QB_FMT<0b00000>;
221class ADDUH_R_QB_ENC : ADDUH_QB_FMT<0b00010>;
222class SUBUH_QB_ENC : ADDUH_QB_FMT<0b00001>;
223class SUBUH_R_QB_ENC : ADDUH_QB_FMT<0b00011>;
224class ADDQH_PH_ENC : ADDUH_QB_FMT<0b01000>;
225class ADDQH_R_PH_ENC : ADDUH_QB_FMT<0b01010>;
226class SUBQH_PH_ENC : ADDUH_QB_FMT<0b01001>;
227class SUBQH_R_PH_ENC : ADDUH_QB_FMT<0b01011>;
228class ADDQH_W_ENC : ADDUH_QB_FMT<0b10000>;
229class ADDQH_R_W_ENC : ADDUH_QB_FMT<0b10010>;
230class SUBQH_W_ENC : ADDUH_QB_FMT<0b10001>;
231class SUBQH_R_W_ENC : ADDUH_QB_FMT<0b10011>;
232class MUL_PH_ENC : ADDUH_QB_FMT<0b01100>;
233class MUL_S_PH_ENC : ADDUH_QB_FMT<0b01110>;
234class MULQ_S_W_ENC : ADDUH_QB_FMT<0b10110>;
235class MULQ_RS_W_ENC : ADDUH_QB_FMT<0b10111>;
236class MULQ_S_PH_ENC : ADDU_QB_FMT<0b11110>;
237class DPA_W_PH_ENC : DPA_W_PH_FMT<0b00000>;
238class DPS_W_PH_ENC : DPA_W_PH_FMT<0b00001>;
239class DPAQX_S_W_PH_ENC : DPA_W_PH_FMT<0b11000>;
240class DPAQX_SA_W_PH_ENC : DPA_W_PH_FMT<0b11010>;
241class DPAX_W_PH_ENC : DPA_W_PH_FMT<0b01000>;
242class DPSX_W_PH_ENC : DPA_W_PH_FMT<0b01001>;
243class DPSQX_S_W_PH_ENC : DPA_W_PH_FMT<0b11001>;
244class DPSQX_SA_W_PH_ENC : DPA_W_PH_FMT<0b11011>;
245class MULSA_W_PH_ENC : DPA_W_PH_FMT<0b00010>;
246class PRECR_QB_PH_ENC : CMP_EQ_QB_R3_FMT<0b01101>;
247class PRECR_SRA_PH_W_ENC : PRECR_SRA_PH_W_FMT<0b11110>;
248class PRECR_SRA_R_PH_W_ENC : PRECR_SRA_PH_W_FMT<0b11111>;
249class SHRA_QB_ENC : SHLL_QB_FMT<0b00100>;
250class SHRAV_QB_ENC : SHLL_QB_FMT<0b00110>;
251class SHRA_R_QB_ENC : SHLL_QB_FMT<0b00101>;
252class SHRAV_R_QB_ENC : SHLL_QB_FMT<0b00111>;
253class SHRL_PH_ENC : SHLL_QB_FMT<0b11001>;
254class SHRLV_PH_ENC : SHLL_QB_FMT<0b11011>;
255class APPEND_ENC : APPEND_FMT<0b00000>;
256class BALIGN_ENC : APPEND_FMT<0b10000>;
257class PREPEND_ENC : APPEND_FMT<0b00001>;
258
259// Instruction desc.
260class ADDU_QB_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
261                        InstrItinClass itin, RegisterOperand ROD,
262                        RegisterOperand ROS,  RegisterOperand ROT = ROS> {
263  dag OutOperandList = (outs ROD:$rd);
264  dag InOperandList = (ins ROS:$rs, ROT:$rt);
265  string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
266  list<dag> Pattern = [(set ROD:$rd, (OpNode ROS:$rs, ROT:$rt))];
267  InstrItinClass Itinerary = itin;
268  string BaseOpcode = instr_asm;
269}
270
271class RADDU_W_QB_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
272                           InstrItinClass itin, RegisterOperand ROD,
273                           RegisterOperand ROS = ROD> {
274  dag OutOperandList = (outs ROD:$rd);
275  dag InOperandList = (ins ROS:$rs);
276  string AsmString = !strconcat(instr_asm, "\t$rd, $rs");
277  list<dag> Pattern = [(set ROD:$rd, (OpNode ROS:$rs))];
278  InstrItinClass Itinerary = itin;
279  string BaseOpcode = instr_asm;
280}
281
282class CMP_EQ_QB_R2_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
283                             InstrItinClass itin, RegisterOperand ROS,
284                             RegisterOperand ROT = ROS> {
285  dag OutOperandList = (outs);
286  dag InOperandList = (ins ROS:$rs, ROT:$rt);
287  string AsmString = !strconcat(instr_asm, "\t$rs, $rt");
288  list<dag> Pattern = [(OpNode ROS:$rs, ROT:$rt)];
289  InstrItinClass Itinerary = itin;
290  string BaseOpcode = instr_asm;
291}
292
293class CMP_EQ_QB_R3_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
294                             InstrItinClass itin, RegisterOperand ROD,
295                             RegisterOperand ROS,  RegisterOperand ROT = ROS> {
296  dag OutOperandList = (outs ROD:$rd);
297  dag InOperandList = (ins ROS:$rs, ROT:$rt);
298  string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
299  list<dag> Pattern = [(set ROD:$rd, (OpNode ROS:$rs, ROT:$rt))];
300  InstrItinClass Itinerary = itin;
301  string BaseOpcode = instr_asm;
302}
303
304class PRECR_SRA_PH_W_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
305                               InstrItinClass itin, RegisterOperand ROT,
306                               RegisterOperand ROS = ROT> {
307  dag OutOperandList = (outs ROT:$rt);
308  dag InOperandList = (ins ROS:$rs, uimm5:$sa, ROS:$src);
309  string AsmString = !strconcat(instr_asm, "\t$rt, $rs, $sa");
310  list<dag> Pattern = [(set ROT:$rt, (OpNode ROS:$src, ROS:$rs, immZExt5:$sa))];
311  InstrItinClass Itinerary = itin;
312  string Constraints = "$src = $rt";
313  string BaseOpcode = instr_asm;
314}
315
316class ABSQ_S_PH_R2_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
317                             InstrItinClass itin, RegisterOperand ROD,
318                             RegisterOperand ROT = ROD> {
319  dag OutOperandList = (outs ROD:$rd);
320  dag InOperandList = (ins ROT:$rt);
321  string AsmString = !strconcat(instr_asm, "\t$rd, $rt");
322  list<dag> Pattern = [(set ROD:$rd, (OpNode ROT:$rt))];
323  InstrItinClass Itinerary = itin;
324  string BaseOpcode = instr_asm;
325}
326
327class REPL_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
328                     Operand ImmOp, ImmLeaf immPat, InstrItinClass itin,
329                     RegisterOperand RO> {
330  dag OutOperandList = (outs RO:$rd);
331  dag InOperandList = (ins ImmOp:$imm);
332  string AsmString = !strconcat(instr_asm, "\t$rd, $imm");
333  list<dag> Pattern = [(set RO:$rd, (OpNode immPat:$imm))];
334  InstrItinClass Itinerary = itin;
335  string BaseOpcode = instr_asm;
336}
337
338class SHLL_QB_R3_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
339                           InstrItinClass itin, RegisterOperand RO> {
340  dag OutOperandList = (outs RO:$rd);
341  dag InOperandList =  (ins RO:$rt, GPR32Opnd:$rs_sa);
342  string AsmString = !strconcat(instr_asm, "\t$rd, $rt, $rs_sa");
343  list<dag> Pattern = [(set RO:$rd, (OpNode RO:$rt, GPR32Opnd:$rs_sa))];
344  InstrItinClass Itinerary = itin;
345  string BaseOpcode = instr_asm;
346}
347
348class SHLL_QB_R2_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
349                           SDPatternOperator ImmPat, InstrItinClass itin,
350                           RegisterOperand RO, Operand ImmOpnd> {
351  dag OutOperandList = (outs RO:$rd);
352  dag InOperandList = (ins RO:$rt, ImmOpnd:$rs_sa);
353  string AsmString = !strconcat(instr_asm, "\t$rd, $rt, $rs_sa");
354  list<dag> Pattern = [(set RO:$rd, (OpNode RO:$rt, ImmPat:$rs_sa))];
355  InstrItinClass Itinerary = itin;
356  bit hasSideEffects = 1;
357  string BaseOpcode = instr_asm;
358}
359
360class LX_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
361                   InstrItinClass itin> {
362  dag OutOperandList = (outs GPR32Opnd:$rd);
363  dag InOperandList = (ins PtrRC:$base, PtrRC:$index);
364  string AsmString = !strconcat(instr_asm, "\t$rd, ${index}(${base})");
365  list<dag> Pattern = [(set GPR32Opnd:$rd, (OpNode iPTR:$base, iPTR:$index))];
366  InstrItinClass Itinerary = itin;
367  bit mayLoad = 1;
368  string BaseOpcode = instr_asm;
369}
370
371class ADDUH_QB_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
372                         InstrItinClass itin, RegisterOperand ROD,
373                         RegisterOperand ROS = ROD,  RegisterOperand ROT = ROD> {
374  dag OutOperandList = (outs ROD:$rd);
375  dag InOperandList = (ins ROS:$rs, ROT:$rt);
376  string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
377  list<dag> Pattern = [(set ROD:$rd, (OpNode ROS:$rs, ROT:$rt))];
378  InstrItinClass Itinerary = itin;
379  string BaseOpcode = instr_asm;
380}
381
382class APPEND_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
383                       Operand ImmOp, SDPatternOperator Imm, InstrItinClass itin> {
384  dag OutOperandList = (outs GPR32Opnd:$rt);
385  dag InOperandList = (ins GPR32Opnd:$rs, ImmOp:$sa, GPR32Opnd:$src);
386  string AsmString = !strconcat(instr_asm, "\t$rt, $rs, $sa");
387  list<dag> Pattern =  [(set GPR32Opnd:$rt,
388                        (OpNode GPR32Opnd:$src, GPR32Opnd:$rs, Imm:$sa))];
389  InstrItinClass Itinerary = itin;
390  string Constraints = "$src = $rt";
391  string BaseOpcode = instr_asm;
392}
393
394class EXTR_W_TY1_R2_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
395                              InstrItinClass itin> {
396  dag OutOperandList = (outs GPR32Opnd:$rt);
397  dag InOperandList = (ins ACC64DSPOpnd:$ac, GPR32Opnd:$shift_rs);
398  string AsmString = !strconcat(instr_asm, "\t$rt, $ac, $shift_rs");
399  InstrItinClass Itinerary = itin;
400  string BaseOpcode = instr_asm;
401}
402
403class EXTR_W_TY1_R1_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
404                              InstrItinClass itin> {
405  dag OutOperandList = (outs GPR32Opnd:$rt);
406  dag InOperandList = (ins ACC64DSPOpnd:$ac, uimm5:$shift_rs);
407  string AsmString = !strconcat(instr_asm, "\t$rt, $ac, $shift_rs");
408  InstrItinClass Itinerary = itin;
409  string BaseOpcode = instr_asm;
410}
411
412class SHILO_R1_DESC_BASE<string instr_asm, SDPatternOperator OpNode> {
413  dag OutOperandList = (outs ACC64DSPOpnd:$ac);
414  dag InOperandList = (ins simm6:$shift, ACC64DSPOpnd:$acin);
415  string AsmString = !strconcat(instr_asm, "\t$ac, $shift");
416  list<dag> Pattern = [(set ACC64DSPOpnd:$ac,
417                        (OpNode immSExt6:$shift, ACC64DSPOpnd:$acin))];
418  string Constraints = "$acin = $ac";
419  string BaseOpcode = instr_asm;
420}
421
422class SHILO_R2_DESC_BASE<string instr_asm, SDPatternOperator OpNode> {
423  dag OutOperandList = (outs ACC64DSPOpnd:$ac);
424  dag InOperandList = (ins GPR32Opnd:$rs, ACC64DSPOpnd:$acin);
425  string AsmString = !strconcat(instr_asm, "\t$ac, $rs");
426  list<dag> Pattern = [(set ACC64DSPOpnd:$ac,
427                        (OpNode GPR32Opnd:$rs, ACC64DSPOpnd:$acin))];
428  string Constraints = "$acin = $ac";
429  string BaseOpcode = instr_asm;
430}
431
432class MTHLIP_DESC_BASE<string instr_asm, SDPatternOperator OpNode> {
433  dag OutOperandList = (outs ACC64DSPOpnd:$ac);
434  dag InOperandList = (ins GPR32Opnd:$rs, ACC64DSPOpnd:$acin);
435  string AsmString = !strconcat(instr_asm, "\t$rs, $ac");
436  list<dag> Pattern = [(set ACC64DSPOpnd:$ac,
437                        (OpNode GPR32Opnd:$rs, ACC64DSPOpnd:$acin))];
438  string Constraints = "$acin = $ac";
439  string BaseOpcode = instr_asm;
440}
441
442class RDDSP_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
443                      InstrItinClass itin> {
444  dag OutOperandList = (outs GPR32Opnd:$rd);
445  dag InOperandList = (ins uimm10:$mask);
446  string AsmString = !strconcat(instr_asm, "\t$rd, $mask");
447  list<dag> Pattern = [(set GPR32Opnd:$rd, (OpNode immZExt10:$mask))];
448  InstrItinClass Itinerary = itin;
449  string BaseOpcode = instr_asm;
450  bit isMoveReg = 1;
451}
452
453class WRDSP_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
454                      InstrItinClass itin> {
455  dag OutOperandList = (outs);
456  dag InOperandList = (ins GPR32Opnd:$rs, uimm10:$mask);
457  string AsmString = !strconcat(instr_asm, "\t$rs, $mask");
458  list<dag> Pattern = [(OpNode GPR32Opnd:$rs, immZExt10:$mask)];
459  InstrItinClass Itinerary = itin;
460  string BaseOpcode = instr_asm;
461  bit isMoveReg = 1;
462}
463
464class DPA_W_PH_DESC_BASE<string instr_asm, SDPatternOperator OpNode> {
465  dag OutOperandList = (outs ACC64DSPOpnd:$ac);
466  dag InOperandList = (ins GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64DSPOpnd:$acin);
467  string AsmString = !strconcat(instr_asm, "\t$ac, $rs, $rt");
468  list<dag> Pattern = [(set ACC64DSPOpnd:$ac,
469                        (OpNode GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64DSPOpnd:$acin))];
470  string Constraints = "$acin = $ac";
471  string BaseOpcode = instr_asm;
472}
473
474class MULT_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
475                     InstrItinClass itin> {
476  dag OutOperandList = (outs ACC64DSPOpnd:$ac);
477  dag InOperandList = (ins GPR32Opnd:$rs, GPR32Opnd:$rt);
478  string AsmString = !strconcat(instr_asm, "\t$ac, $rs, $rt");
479  list<dag> Pattern = [(set ACC64DSPOpnd:$ac, (OpNode GPR32Opnd:$rs, GPR32Opnd:$rt))];
480  InstrItinClass Itinerary = itin;
481  bit isCommutable = 1;
482  string BaseOpcode = instr_asm;
483}
484
485class MADD_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
486                     InstrItinClass itin> {
487  dag OutOperandList = (outs ACC64DSPOpnd:$ac);
488  dag InOperandList = (ins GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64DSPOpnd:$acin);
489  string AsmString = !strconcat(instr_asm, "\t$ac, $rs, $rt");
490  list<dag> Pattern = [(set ACC64DSPOpnd:$ac,
491                        (OpNode GPR32Opnd:$rs, GPR32Opnd:$rt, ACC64DSPOpnd:$acin))];
492  InstrItinClass Itinerary = itin;
493  string Constraints = "$acin = $ac";
494  string BaseOpcode = instr_asm;
495}
496
497class MFHI_DESC_BASE<string instr_asm, RegisterOperand RO, SDNode OpNode,
498                     InstrItinClass itin> {
499  dag OutOperandList = (outs GPR32Opnd:$rd);
500  dag InOperandList = (ins RO:$ac);
501  string AsmString = !strconcat(instr_asm, "\t$rd, $ac");
502  list<dag> Pattern = [(set GPR32Opnd:$rd, (OpNode RO:$ac))];
503  InstrItinClass Itinerary = itin;
504  string BaseOpcode = instr_asm;
505  bit isMoveReg = 1;
506}
507
508class MTHI_DESC_BASE<string instr_asm, RegisterOperand RO, InstrItinClass itin> {
509  dag OutOperandList = (outs RO:$ac);
510  dag InOperandList = (ins GPR32Opnd:$rs);
511  string AsmString = !strconcat(instr_asm, "\t$rs, $ac");
512  InstrItinClass Itinerary = itin;
513  string BaseOpcode = instr_asm;
514  bit isMoveReg = 1;
515}
516
517class BPOSGE32_PSEUDO_DESC_BASE<SDPatternOperator OpNode, InstrItinClass itin> :
518  MipsPseudo<(outs GPR32Opnd:$dst), (ins), [(set GPR32Opnd:$dst, (OpNode))]> {
519  bit usesCustomInserter = 1;
520}
521
522class BPOSGE32_DESC_BASE<string instr_asm, DAGOperand opnd,
523                         InstrItinClass itin> {
524  dag OutOperandList = (outs);
525  dag InOperandList = (ins opnd:$offset);
526  string AsmString = !strconcat(instr_asm, "\t$offset");
527  InstrItinClass Itinerary = itin;
528  bit isBranch = 1;
529  bit isTerminator = 1;
530  bit hasDelaySlot = 1;
531  string BaseOpcode = instr_asm;
532}
533
534class INSV_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
535                     InstrItinClass itin> {
536  dag OutOperandList = (outs GPR32Opnd:$rt);
537  dag InOperandList = (ins GPR32Opnd:$src, GPR32Opnd:$rs);
538  string AsmString = !strconcat(instr_asm, "\t$rt, $rs");
539  list<dag> Pattern = [(set GPR32Opnd:$rt, (OpNode GPR32Opnd:$src, GPR32Opnd:$rs))];
540  InstrItinClass Itinerary = itin;
541  string Constraints = "$src = $rt";
542  string BaseOpcode = instr_asm;
543}
544
545//===----------------------------------------------------------------------===//
546// MIPS DSP Rev 1
547//===----------------------------------------------------------------------===//
548
549// Addition/subtraction
550class ADDU_QB_DESC : ADDU_QB_DESC_BASE<"addu.qb", null_frag, NoItinerary,
551                                       DSPROpnd, DSPROpnd>, IsCommutable,
552                     Defs<[DSPOutFlag20]>;
553
554class ADDU_S_QB_DESC : ADDU_QB_DESC_BASE<"addu_s.qb", int_mips_addu_s_qb,
555                                         NoItinerary, DSPROpnd, DSPROpnd>,
556                       IsCommutable, Defs<[DSPOutFlag20]>;
557
558class SUBU_QB_DESC : ADDU_QB_DESC_BASE<"subu.qb", null_frag, NoItinerary,
559                                       DSPROpnd, DSPROpnd>,
560                     Defs<[DSPOutFlag20]>;
561
562class SUBU_S_QB_DESC : ADDU_QB_DESC_BASE<"subu_s.qb", int_mips_subu_s_qb,
563                                         NoItinerary, DSPROpnd, DSPROpnd>,
564                       Defs<[DSPOutFlag20]>;
565
566class ADDQ_PH_DESC : ADDU_QB_DESC_BASE<"addq.ph", null_frag, NoItinerary,
567                                       DSPROpnd, DSPROpnd>, IsCommutable,
568                     Defs<[DSPOutFlag20]>;
569
570class ADDQ_S_PH_DESC : ADDU_QB_DESC_BASE<"addq_s.ph", int_mips_addq_s_ph,
571                                         NoItinerary, DSPROpnd, DSPROpnd>,
572                       IsCommutable, Defs<[DSPOutFlag20]>;
573
574class SUBQ_PH_DESC : ADDU_QB_DESC_BASE<"subq.ph", null_frag, NoItinerary,
575                                       DSPROpnd, DSPROpnd>,
576                     Defs<[DSPOutFlag20]>;
577
578class SUBQ_S_PH_DESC : ADDU_QB_DESC_BASE<"subq_s.ph", int_mips_subq_s_ph,
579                                         NoItinerary, DSPROpnd, DSPROpnd>,
580                       Defs<[DSPOutFlag20]>;
581
582class ADDQ_S_W_DESC : ADDU_QB_DESC_BASE<"addq_s.w", int_mips_addq_s_w,
583                                        NoItinerary, GPR32Opnd, GPR32Opnd>,
584                      IsCommutable, Defs<[DSPOutFlag20]>;
585
586class SUBQ_S_W_DESC : ADDU_QB_DESC_BASE<"subq_s.w", int_mips_subq_s_w,
587                                        NoItinerary, GPR32Opnd, GPR32Opnd>,
588                      Defs<[DSPOutFlag20]>;
589
590class ADDSC_DESC : ADDU_QB_DESC_BASE<"addsc", null_frag, NoItinerary,
591                                     GPR32Opnd, GPR32Opnd>, IsCommutable,
592                   Defs<[DSPCarry]>;
593
594class ADDWC_DESC : ADDU_QB_DESC_BASE<"addwc", null_frag, NoItinerary,
595                                     GPR32Opnd, GPR32Opnd>,
596                   IsCommutable, Uses<[DSPCarry]>, Defs<[DSPOutFlag20]>;
597
598class MODSUB_DESC : ADDU_QB_DESC_BASE<"modsub", int_mips_modsub, NoItinerary,
599                                      GPR32Opnd, GPR32Opnd>;
600
601class RADDU_W_QB_DESC : RADDU_W_QB_DESC_BASE<"raddu.w.qb", int_mips_raddu_w_qb,
602                                             NoItinerary, GPR32Opnd, DSPROpnd>;
603
604// Absolute value
605class ABSQ_S_PH_DESC : ABSQ_S_PH_R2_DESC_BASE<"absq_s.ph", int_mips_absq_s_ph,
606                                              NoItinerary, DSPROpnd>,
607                       Defs<[DSPOutFlag20]>;
608
609class ABSQ_S_W_DESC : ABSQ_S_PH_R2_DESC_BASE<"absq_s.w", int_mips_absq_s_w,
610                                             NoItinerary, GPR32Opnd>,
611                      Defs<[DSPOutFlag20]>;
612
613// Precision reduce/expand
614class PRECRQ_QB_PH_DESC : CMP_EQ_QB_R3_DESC_BASE<"precrq.qb.ph",
615                                                 int_mips_precrq_qb_ph,
616                                                 NoItinerary, DSPROpnd, DSPROpnd>;
617
618class PRECRQ_PH_W_DESC : CMP_EQ_QB_R3_DESC_BASE<"precrq.ph.w",
619                                                int_mips_precrq_ph_w,
620                                                NoItinerary, DSPROpnd, GPR32Opnd>;
621
622class PRECRQ_RS_PH_W_DESC : CMP_EQ_QB_R3_DESC_BASE<"precrq_rs.ph.w",
623                                                   int_mips_precrq_rs_ph_w,
624                                                   NoItinerary, DSPROpnd,
625                                                   GPR32Opnd>,
626                            Defs<[DSPOutFlag22]>;
627
628class PRECRQU_S_QB_PH_DESC : CMP_EQ_QB_R3_DESC_BASE<"precrqu_s.qb.ph",
629                                                    int_mips_precrqu_s_qb_ph,
630                                                    NoItinerary, DSPROpnd,
631                                                    DSPROpnd>,
632                             Defs<[DSPOutFlag22]>;
633
634class PRECEQ_W_PHL_DESC : ABSQ_S_PH_R2_DESC_BASE<"preceq.w.phl",
635                                                 int_mips_preceq_w_phl,
636                                                 NoItinerary, GPR32Opnd, DSPROpnd>;
637
638class PRECEQ_W_PHR_DESC : ABSQ_S_PH_R2_DESC_BASE<"preceq.w.phr",
639                                                 int_mips_preceq_w_phr,
640                                                 NoItinerary, GPR32Opnd, DSPROpnd>;
641
642class PRECEQU_PH_QBL_DESC : ABSQ_S_PH_R2_DESC_BASE<"precequ.ph.qbl",
643                                                   int_mips_precequ_ph_qbl,
644                                                   NoItinerary, DSPROpnd>;
645
646class PRECEQU_PH_QBR_DESC : ABSQ_S_PH_R2_DESC_BASE<"precequ.ph.qbr",
647                                                   int_mips_precequ_ph_qbr,
648                                                   NoItinerary, DSPROpnd>;
649
650class PRECEQU_PH_QBLA_DESC : ABSQ_S_PH_R2_DESC_BASE<"precequ.ph.qbla",
651                                                    int_mips_precequ_ph_qbla,
652                                                    NoItinerary, DSPROpnd>;
653
654class PRECEQU_PH_QBRA_DESC : ABSQ_S_PH_R2_DESC_BASE<"precequ.ph.qbra",
655                                                    int_mips_precequ_ph_qbra,
656                                                    NoItinerary, DSPROpnd>;
657
658class PRECEU_PH_QBL_DESC : ABSQ_S_PH_R2_DESC_BASE<"preceu.ph.qbl",
659                                                  int_mips_preceu_ph_qbl,
660                                                  NoItinerary, DSPROpnd>;
661
662class PRECEU_PH_QBR_DESC : ABSQ_S_PH_R2_DESC_BASE<"preceu.ph.qbr",
663                                                  int_mips_preceu_ph_qbr,
664                                                  NoItinerary, DSPROpnd>;
665
666class PRECEU_PH_QBLA_DESC : ABSQ_S_PH_R2_DESC_BASE<"preceu.ph.qbla",
667                                                   int_mips_preceu_ph_qbla,
668                                                   NoItinerary, DSPROpnd>;
669
670class PRECEU_PH_QBRA_DESC : ABSQ_S_PH_R2_DESC_BASE<"preceu.ph.qbra",
671                                                   int_mips_preceu_ph_qbra,
672                                                   NoItinerary, DSPROpnd>;
673
674// Shift
675class SHLL_QB_DESC : SHLL_QB_R2_DESC_BASE<"shll.qb", null_frag, immZExt3,
676                                          NoItinerary, DSPROpnd, uimm3>,
677                     Defs<[DSPOutFlag22]>;
678
679class SHLLV_QB_DESC : SHLL_QB_R3_DESC_BASE<"shllv.qb", int_mips_shll_qb,
680                                           NoItinerary, DSPROpnd>,
681                      Defs<[DSPOutFlag22]>;
682
683class SHRL_QB_DESC : SHLL_QB_R2_DESC_BASE<"shrl.qb", null_frag, immZExt3,
684                                          NoItinerary, DSPROpnd, uimm3>;
685
686class SHRLV_QB_DESC : SHLL_QB_R3_DESC_BASE<"shrlv.qb", int_mips_shrl_qb,
687                                           NoItinerary, DSPROpnd>;
688
689class SHLL_PH_DESC : SHLL_QB_R2_DESC_BASE<"shll.ph", null_frag, immZExt4,
690                                          NoItinerary, DSPROpnd, uimm4>,
691                     Defs<[DSPOutFlag22]>;
692
693class SHLLV_PH_DESC : SHLL_QB_R3_DESC_BASE<"shllv.ph", int_mips_shll_ph,
694                                           NoItinerary, DSPROpnd>,
695                      Defs<[DSPOutFlag22]>;
696
697class SHLL_S_PH_DESC : SHLL_QB_R2_DESC_BASE<"shll_s.ph", int_mips_shll_s_ph,
698                                            immZExt4, NoItinerary, DSPROpnd,
699                                            uimm4>,
700                       Defs<[DSPOutFlag22]>;
701
702class SHLLV_S_PH_DESC : SHLL_QB_R3_DESC_BASE<"shllv_s.ph", int_mips_shll_s_ph,
703                                             NoItinerary, DSPROpnd>,
704                        Defs<[DSPOutFlag22]>;
705
706class SHRA_PH_DESC : SHLL_QB_R2_DESC_BASE<"shra.ph", null_frag, immZExt4,
707                                          NoItinerary, DSPROpnd, uimm4>;
708
709class SHRAV_PH_DESC : SHLL_QB_R3_DESC_BASE<"shrav.ph", int_mips_shra_ph,
710                                           NoItinerary, DSPROpnd>;
711
712class SHRA_R_PH_DESC : SHLL_QB_R2_DESC_BASE<"shra_r.ph", int_mips_shra_r_ph,
713                                            immZExt4, NoItinerary, DSPROpnd,
714                                            uimm4>;
715
716class SHRAV_R_PH_DESC : SHLL_QB_R3_DESC_BASE<"shrav_r.ph", int_mips_shra_r_ph,
717                                             NoItinerary, DSPROpnd>;
718
719class SHLL_S_W_DESC : SHLL_QB_R2_DESC_BASE<"shll_s.w", int_mips_shll_s_w,
720                                           immZExt5, NoItinerary, GPR32Opnd,
721                                           uimm5>,
722                      Defs<[DSPOutFlag22]>;
723
724class SHLLV_S_W_DESC : SHLL_QB_R3_DESC_BASE<"shllv_s.w", int_mips_shll_s_w,
725                                            NoItinerary, GPR32Opnd>,
726                       Defs<[DSPOutFlag22]>;
727
728class SHRA_R_W_DESC : SHLL_QB_R2_DESC_BASE<"shra_r.w", int_mips_shra_r_w,
729                                           immZExt5, NoItinerary, GPR32Opnd,
730                                           uimm5>;
731
732class SHRAV_R_W_DESC : SHLL_QB_R3_DESC_BASE<"shrav_r.w", int_mips_shra_r_w,
733                                            NoItinerary, GPR32Opnd>;
734
735// Multiplication
736class MULEU_S_PH_QBL_DESC : ADDU_QB_DESC_BASE<"muleu_s.ph.qbl",
737                                              int_mips_muleu_s_ph_qbl,
738                                              NoItinerary, DSPROpnd, DSPROpnd>,
739                            Defs<[DSPOutFlag21]>;
740
741class MULEU_S_PH_QBR_DESC : ADDU_QB_DESC_BASE<"muleu_s.ph.qbr",
742                                              int_mips_muleu_s_ph_qbr,
743                                              NoItinerary, DSPROpnd, DSPROpnd>,
744                            Defs<[DSPOutFlag21]>;
745
746class MULEQ_S_W_PHL_DESC : ADDU_QB_DESC_BASE<"muleq_s.w.phl",
747                                             int_mips_muleq_s_w_phl,
748                                             NoItinerary, GPR32Opnd, DSPROpnd>,
749                           IsCommutable, Defs<[DSPOutFlag21]>;
750
751class MULEQ_S_W_PHR_DESC : ADDU_QB_DESC_BASE<"muleq_s.w.phr",
752                                             int_mips_muleq_s_w_phr,
753                                             NoItinerary, GPR32Opnd, DSPROpnd>,
754                           IsCommutable, Defs<[DSPOutFlag21]>;
755
756class MULQ_RS_PH_DESC : ADDU_QB_DESC_BASE<"mulq_rs.ph", int_mips_mulq_rs_ph,
757                                          NoItinerary, DSPROpnd, DSPROpnd>,
758                        IsCommutable, Defs<[DSPOutFlag21]>;
759
760class MULSAQ_S_W_PH_DESC : DPA_W_PH_DESC_BASE<"mulsaq_s.w.ph",
761                                              MipsMULSAQ_S_W_PH>,
762                           Defs<[DSPOutFlag16_19]>;
763
764class MAQ_S_W_PHL_DESC : DPA_W_PH_DESC_BASE<"maq_s.w.phl", MipsMAQ_S_W_PHL>,
765                         Defs<[DSPOutFlag16_19]>;
766
767class MAQ_S_W_PHR_DESC : DPA_W_PH_DESC_BASE<"maq_s.w.phr", MipsMAQ_S_W_PHR>,
768                         Defs<[DSPOutFlag16_19]>;
769
770class MAQ_SA_W_PHL_DESC : DPA_W_PH_DESC_BASE<"maq_sa.w.phl", MipsMAQ_SA_W_PHL>,
771                          Defs<[DSPOutFlag16_19]>;
772
773class MAQ_SA_W_PHR_DESC : DPA_W_PH_DESC_BASE<"maq_sa.w.phr", MipsMAQ_SA_W_PHR>,
774                          Defs<[DSPOutFlag16_19]>;
775
776// Move from/to hi/lo.
777class MFHI_DESC : MFHI_DESC_BASE<"mfhi", ACC64DSPOpnd, MipsMFHI, NoItinerary>;
778class MFLO_DESC : MFHI_DESC_BASE<"mflo", ACC64DSPOpnd, MipsMFLO, NoItinerary>;
779class MTHI_DESC : MTHI_DESC_BASE<"mthi", HI32DSPOpnd, NoItinerary>;
780class MTLO_DESC : MTHI_DESC_BASE<"mtlo", LO32DSPOpnd, NoItinerary>;
781
782// Dot product with accumulate/subtract
783class DPAU_H_QBL_DESC : DPA_W_PH_DESC_BASE<"dpau.h.qbl", MipsDPAU_H_QBL>;
784
785class DPAU_H_QBR_DESC : DPA_W_PH_DESC_BASE<"dpau.h.qbr", MipsDPAU_H_QBR>;
786
787class DPSU_H_QBL_DESC : DPA_W_PH_DESC_BASE<"dpsu.h.qbl", MipsDPSU_H_QBL>;
788
789class DPSU_H_QBR_DESC : DPA_W_PH_DESC_BASE<"dpsu.h.qbr", MipsDPSU_H_QBR>;
790
791class DPAQ_S_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpaq_s.w.ph", MipsDPAQ_S_W_PH>,
792                         Defs<[DSPOutFlag16_19]>;
793
794class DPSQ_S_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpsq_s.w.ph", MipsDPSQ_S_W_PH>,
795                         Defs<[DSPOutFlag16_19]>;
796
797class DPAQ_SA_L_W_DESC : DPA_W_PH_DESC_BASE<"dpaq_sa.l.w", MipsDPAQ_SA_L_W>,
798                         Defs<[DSPOutFlag16_19]>;
799
800class DPSQ_SA_L_W_DESC : DPA_W_PH_DESC_BASE<"dpsq_sa.l.w", MipsDPSQ_SA_L_W>,
801                         Defs<[DSPOutFlag16_19]>;
802
803class MULT_DSP_DESC  : MULT_DESC_BASE<"mult", MipsMult, NoItinerary>;
804class MULTU_DSP_DESC : MULT_DESC_BASE<"multu", MipsMultu, NoItinerary>;
805class MADD_DSP_DESC  : MADD_DESC_BASE<"madd", MipsMAdd, NoItinerary>;
806class MADDU_DSP_DESC : MADD_DESC_BASE<"maddu", MipsMAddu, NoItinerary>;
807class MSUB_DSP_DESC  : MADD_DESC_BASE<"msub", MipsMSub, NoItinerary>;
808class MSUBU_DSP_DESC : MADD_DESC_BASE<"msubu", MipsMSubu, NoItinerary>;
809
810// Comparison
811class CMPU_EQ_QB_DESC : CMP_EQ_QB_R2_DESC_BASE<"cmpu.eq.qb",
812                                               int_mips_cmpu_eq_qb, NoItinerary,
813                                               DSPROpnd>,
814                        IsCommutable, Defs<[DSPCCond]>;
815
816class CMPU_LT_QB_DESC : CMP_EQ_QB_R2_DESC_BASE<"cmpu.lt.qb",
817                                               int_mips_cmpu_lt_qb, NoItinerary,
818                                               DSPROpnd>, Defs<[DSPCCond]>;
819
820class CMPU_LE_QB_DESC : CMP_EQ_QB_R2_DESC_BASE<"cmpu.le.qb",
821                                               int_mips_cmpu_le_qb, NoItinerary,
822                                               DSPROpnd>, Defs<[DSPCCond]>;
823
824class CMPGU_EQ_QB_DESC : CMP_EQ_QB_R3_DESC_BASE<"cmpgu.eq.qb",
825                                                int_mips_cmpgu_eq_qb,
826                                                NoItinerary, GPR32Opnd, DSPROpnd>,
827                         IsCommutable;
828
829class CMPGU_LT_QB_DESC : CMP_EQ_QB_R3_DESC_BASE<"cmpgu.lt.qb",
830                                                int_mips_cmpgu_lt_qb,
831                                                NoItinerary, GPR32Opnd, DSPROpnd>;
832
833class CMPGU_LE_QB_DESC : CMP_EQ_QB_R3_DESC_BASE<"cmpgu.le.qb",
834                                                int_mips_cmpgu_le_qb,
835                                                NoItinerary, GPR32Opnd, DSPROpnd>;
836
837class CMP_EQ_PH_DESC : CMP_EQ_QB_R2_DESC_BASE<"cmp.eq.ph", int_mips_cmp_eq_ph,
838                                              NoItinerary, DSPROpnd>,
839                       IsCommutable, Defs<[DSPCCond]>;
840
841class CMP_LT_PH_DESC : CMP_EQ_QB_R2_DESC_BASE<"cmp.lt.ph", int_mips_cmp_lt_ph,
842                                              NoItinerary, DSPROpnd>,
843                       Defs<[DSPCCond]>;
844
845class CMP_LE_PH_DESC : CMP_EQ_QB_R2_DESC_BASE<"cmp.le.ph", int_mips_cmp_le_ph,
846                                              NoItinerary, DSPROpnd>,
847                       Defs<[DSPCCond]>;
848
849// Misc
850class BITREV_DESC : ABSQ_S_PH_R2_DESC_BASE<"bitrev", int_mips_bitrev,
851                                           NoItinerary, GPR32Opnd>;
852
853class PACKRL_PH_DESC : CMP_EQ_QB_R3_DESC_BASE<"packrl.ph", int_mips_packrl_ph,
854                                              NoItinerary, DSPROpnd, DSPROpnd>;
855
856class REPL_QB_DESC : REPL_DESC_BASE<"repl.qb", int_mips_repl_qb, uimm8,
857                                    immZExt8, NoItinerary, DSPROpnd>;
858
859class REPL_PH_DESC : REPL_DESC_BASE<"repl.ph", int_mips_repl_ph, simm10,
860                                    immSExt10, NoItinerary, DSPROpnd>;
861
862class REPLV_QB_DESC : ABSQ_S_PH_R2_DESC_BASE<"replv.qb", int_mips_repl_qb,
863                                             NoItinerary, DSPROpnd, GPR32Opnd>;
864
865class REPLV_PH_DESC : ABSQ_S_PH_R2_DESC_BASE<"replv.ph", int_mips_repl_ph,
866                                             NoItinerary, DSPROpnd, GPR32Opnd>;
867
868class PICK_QB_DESC : CMP_EQ_QB_R3_DESC_BASE<"pick.qb", int_mips_pick_qb,
869                                            NoItinerary, DSPROpnd, DSPROpnd>,
870                     Uses<[DSPCCond]>;
871
872class PICK_PH_DESC : CMP_EQ_QB_R3_DESC_BASE<"pick.ph", int_mips_pick_ph,
873                                            NoItinerary, DSPROpnd, DSPROpnd>,
874                     Uses<[DSPCCond]>;
875
876class LWX_DESC : LX_DESC_BASE<"lwx", int_mips_lwx, NoItinerary>;
877
878class LHX_DESC : LX_DESC_BASE<"lhx", int_mips_lhx, NoItinerary>;
879
880class LBUX_DESC : LX_DESC_BASE<"lbux", int_mips_lbux, NoItinerary>;
881
882class BPOSGE32_DESC : BPOSGE32_DESC_BASE<"bposge32", brtarget, NoItinerary>;
883
884// Extr
885class EXTP_DESC : EXTR_W_TY1_R1_DESC_BASE<"extp", MipsEXTP, NoItinerary>,
886                  Uses<[DSPPos]>, Defs<[DSPEFI]>;
887
888class EXTPV_DESC : EXTR_W_TY1_R2_DESC_BASE<"extpv", MipsEXTP, NoItinerary>,
889                   Uses<[DSPPos]>, Defs<[DSPEFI]>;
890
891class EXTPDP_DESC : EXTR_W_TY1_R1_DESC_BASE<"extpdp", MipsEXTPDP, NoItinerary>,
892                    Uses<[DSPPos]>, Defs<[DSPPos, DSPEFI]>;
893
894class EXTPDPV_DESC : EXTR_W_TY1_R2_DESC_BASE<"extpdpv", MipsEXTPDP,
895                                             NoItinerary>,
896                     Uses<[DSPPos]>, Defs<[DSPPos, DSPEFI]>;
897
898class EXTR_W_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr.w", MipsEXTR_W, NoItinerary>,
899                    Defs<[DSPOutFlag23]>;
900
901class EXTRV_W_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv.w", MipsEXTR_W,
902                                             NoItinerary>, Defs<[DSPOutFlag23]>;
903
904class EXTR_R_W_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr_r.w", MipsEXTR_R_W,
905                                              NoItinerary>,
906                      Defs<[DSPOutFlag23]>;
907
908class EXTRV_R_W_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv_r.w", MipsEXTR_R_W,
909                                               NoItinerary>,
910                       Defs<[DSPOutFlag23]>;
911
912class EXTR_RS_W_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr_rs.w", MipsEXTR_RS_W,
913                                               NoItinerary>,
914                       Defs<[DSPOutFlag23]>;
915
916class EXTRV_RS_W_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv_rs.w", MipsEXTR_RS_W,
917                                                NoItinerary>,
918                        Defs<[DSPOutFlag23]>;
919
920class EXTR_S_H_DESC : EXTR_W_TY1_R1_DESC_BASE<"extr_s.h", MipsEXTR_S_H,
921                                              NoItinerary>,
922                      Defs<[DSPOutFlag23]>;
923
924class EXTRV_S_H_DESC : EXTR_W_TY1_R2_DESC_BASE<"extrv_s.h", MipsEXTR_S_H,
925                                               NoItinerary>,
926                       Defs<[DSPOutFlag23]>;
927
928class SHILO_DESC : SHILO_R1_DESC_BASE<"shilo", MipsSHILO>;
929
930class SHILOV_DESC : SHILO_R2_DESC_BASE<"shilov", MipsSHILO>;
931
932class MTHLIP_DESC : MTHLIP_DESC_BASE<"mthlip", MipsMTHLIP>, Defs<[DSPPos]>;
933
934class RDDSP_DESC : RDDSP_DESC_BASE<"rddsp", int_mips_rddsp, NoItinerary>;
935
936class WRDSP_DESC : WRDSP_DESC_BASE<"wrdsp", int_mips_wrdsp, NoItinerary>;
937
938class INSV_DESC : INSV_DESC_BASE<"insv", int_mips_insv, NoItinerary>,
939                  Uses<[DSPPos, DSPSCount]>;
940
941//===----------------------------------------------------------------------===//
942// MIPS DSP Rev 2
943// Addition/subtraction
944class ADDU_PH_DESC : ADDU_QB_DESC_BASE<"addu.ph", int_mips_addu_ph, NoItinerary,
945                                       DSPROpnd, DSPROpnd>, IsCommutable,
946                     Defs<[DSPOutFlag20]>;
947
948class ADDU_S_PH_DESC : ADDU_QB_DESC_BASE<"addu_s.ph", int_mips_addu_s_ph,
949                                         NoItinerary, DSPROpnd, DSPROpnd>,
950                       IsCommutable, Defs<[DSPOutFlag20]>;
951
952class SUBU_PH_DESC : ADDU_QB_DESC_BASE<"subu.ph", int_mips_subu_ph, NoItinerary,
953                                       DSPROpnd, DSPROpnd>,
954                     Defs<[DSPOutFlag20]>;
955
956class SUBU_S_PH_DESC : ADDU_QB_DESC_BASE<"subu_s.ph", int_mips_subu_s_ph,
957                                         NoItinerary, DSPROpnd, DSPROpnd>,
958                       Defs<[DSPOutFlag20]>;
959
960class ADDUH_QB_DESC : ADDUH_QB_DESC_BASE<"adduh.qb", int_mips_adduh_qb,
961                                         NoItinerary, DSPROpnd>, IsCommutable;
962
963class ADDUH_R_QB_DESC : ADDUH_QB_DESC_BASE<"adduh_r.qb", int_mips_adduh_r_qb,
964                                           NoItinerary, DSPROpnd>, IsCommutable;
965
966class SUBUH_QB_DESC : ADDUH_QB_DESC_BASE<"subuh.qb", int_mips_subuh_qb,
967                                         NoItinerary, DSPROpnd>;
968
969class SUBUH_R_QB_DESC : ADDUH_QB_DESC_BASE<"subuh_r.qb", int_mips_subuh_r_qb,
970                                           NoItinerary, DSPROpnd>;
971
972class ADDQH_PH_DESC : ADDUH_QB_DESC_BASE<"addqh.ph", int_mips_addqh_ph,
973                                         NoItinerary, DSPROpnd>, IsCommutable;
974
975class ADDQH_R_PH_DESC : ADDUH_QB_DESC_BASE<"addqh_r.ph", int_mips_addqh_r_ph,
976                                           NoItinerary, DSPROpnd>, IsCommutable;
977
978class SUBQH_PH_DESC : ADDUH_QB_DESC_BASE<"subqh.ph", int_mips_subqh_ph,
979                                         NoItinerary, DSPROpnd>;
980
981class SUBQH_R_PH_DESC : ADDUH_QB_DESC_BASE<"subqh_r.ph", int_mips_subqh_r_ph,
982                                           NoItinerary, DSPROpnd>;
983
984class ADDQH_W_DESC : ADDUH_QB_DESC_BASE<"addqh.w", int_mips_addqh_w,
985                                        NoItinerary, GPR32Opnd>, IsCommutable;
986
987class ADDQH_R_W_DESC : ADDUH_QB_DESC_BASE<"addqh_r.w", int_mips_addqh_r_w,
988                                          NoItinerary, GPR32Opnd>, IsCommutable;
989
990class SUBQH_W_DESC : ADDUH_QB_DESC_BASE<"subqh.w", int_mips_subqh_w,
991                                        NoItinerary, GPR32Opnd>;
992
993class SUBQH_R_W_DESC : ADDUH_QB_DESC_BASE<"subqh_r.w", int_mips_subqh_r_w,
994                                          NoItinerary, GPR32Opnd>;
995
996// Comparison
997class CMPGDU_EQ_QB_DESC : CMP_EQ_QB_R3_DESC_BASE<"cmpgdu.eq.qb",
998                                                 int_mips_cmpgdu_eq_qb,
999                                                 NoItinerary, GPR32Opnd, DSPROpnd>,
1000                          IsCommutable, Defs<[DSPCCond]>;
1001
1002class CMPGDU_LT_QB_DESC : CMP_EQ_QB_R3_DESC_BASE<"cmpgdu.lt.qb",
1003                                                 int_mips_cmpgdu_lt_qb,
1004                                                 NoItinerary, GPR32Opnd, DSPROpnd>,
1005                          Defs<[DSPCCond]>;
1006
1007class CMPGDU_LE_QB_DESC : CMP_EQ_QB_R3_DESC_BASE<"cmpgdu.le.qb",
1008                                                 int_mips_cmpgdu_le_qb,
1009                                                 NoItinerary, GPR32Opnd, DSPROpnd>,
1010                          Defs<[DSPCCond]>;
1011
1012// Absolute
1013class ABSQ_S_QB_DESC : ABSQ_S_PH_R2_DESC_BASE<"absq_s.qb", int_mips_absq_s_qb,
1014                                              NoItinerary, DSPROpnd>,
1015                       Defs<[DSPOutFlag20]>;
1016
1017// Multiplication
1018class MUL_PH_DESC : ADDUH_QB_DESC_BASE<"mul.ph", null_frag, NoItinerary,
1019                                       DSPROpnd>, IsCommutable,
1020                    Defs<[DSPOutFlag21]>;
1021
1022class MUL_S_PH_DESC : ADDUH_QB_DESC_BASE<"mul_s.ph", int_mips_mul_s_ph,
1023                                         NoItinerary, DSPROpnd>, IsCommutable,
1024                      Defs<[DSPOutFlag21]>;
1025
1026class MULQ_S_W_DESC : ADDUH_QB_DESC_BASE<"mulq_s.w", int_mips_mulq_s_w,
1027                                         NoItinerary, GPR32Opnd>, IsCommutable,
1028                      Defs<[DSPOutFlag21]>;
1029
1030class MULQ_RS_W_DESC : ADDUH_QB_DESC_BASE<"mulq_rs.w", int_mips_mulq_rs_w,
1031                                          NoItinerary, GPR32Opnd>, IsCommutable,
1032                       Defs<[DSPOutFlag21]>;
1033
1034class MULQ_S_PH_DESC : ADDU_QB_DESC_BASE<"mulq_s.ph", int_mips_mulq_s_ph,
1035                                         NoItinerary, DSPROpnd, DSPROpnd>,
1036                       IsCommutable, Defs<[DSPOutFlag21]>;
1037
1038// Dot product with accumulate/subtract
1039class DPA_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpa.w.ph", MipsDPA_W_PH>;
1040
1041class DPS_W_PH_DESC : DPA_W_PH_DESC_BASE<"dps.w.ph", MipsDPS_W_PH>;
1042
1043class DPAQX_S_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpaqx_s.w.ph", MipsDPAQX_S_W_PH>,
1044                          Defs<[DSPOutFlag16_19]>;
1045
1046class DPAQX_SA_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpaqx_sa.w.ph",
1047                                              MipsDPAQX_SA_W_PH>,
1048                           Defs<[DSPOutFlag16_19]>;
1049
1050class DPAX_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpax.w.ph", MipsDPAX_W_PH>;
1051
1052class DPSX_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpsx.w.ph", MipsDPSX_W_PH>;
1053
1054class DPSQX_S_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpsqx_s.w.ph", MipsDPSQX_S_W_PH>,
1055                          Defs<[DSPOutFlag16_19]>;
1056
1057class DPSQX_SA_W_PH_DESC : DPA_W_PH_DESC_BASE<"dpsqx_sa.w.ph",
1058                                              MipsDPSQX_SA_W_PH>,
1059                           Defs<[DSPOutFlag16_19]>;
1060
1061class MULSA_W_PH_DESC : DPA_W_PH_DESC_BASE<"mulsa.w.ph", MipsMULSA_W_PH>;
1062
1063// Precision reduce/expand
1064class PRECR_QB_PH_DESC : CMP_EQ_QB_R3_DESC_BASE<"precr.qb.ph",
1065                                                int_mips_precr_qb_ph,
1066                                                NoItinerary, DSPROpnd, DSPROpnd>;
1067
1068class PRECR_SRA_PH_W_DESC : PRECR_SRA_PH_W_DESC_BASE<"precr_sra.ph.w",
1069                                                     int_mips_precr_sra_ph_w,
1070                                                     NoItinerary, DSPROpnd,
1071                                                     GPR32Opnd>;
1072
1073class PRECR_SRA_R_PH_W_DESC : PRECR_SRA_PH_W_DESC_BASE<"precr_sra_r.ph.w",
1074                                                      int_mips_precr_sra_r_ph_w,
1075                                                       NoItinerary, DSPROpnd,
1076                                                       GPR32Opnd>;
1077
1078// Shift
1079class SHRA_QB_DESC : SHLL_QB_R2_DESC_BASE<"shra.qb", null_frag, immZExt3,
1080                                          NoItinerary, DSPROpnd, uimm3>;
1081
1082class SHRAV_QB_DESC : SHLL_QB_R3_DESC_BASE<"shrav.qb", int_mips_shra_qb,
1083                                           NoItinerary, DSPROpnd>;
1084
1085class SHRA_R_QB_DESC : SHLL_QB_R2_DESC_BASE<"shra_r.qb", int_mips_shra_r_qb,
1086                                            immZExt3, NoItinerary, DSPROpnd,
1087                                            uimm3>;
1088
1089class SHRAV_R_QB_DESC : SHLL_QB_R3_DESC_BASE<"shrav_r.qb", int_mips_shra_r_qb,
1090                                             NoItinerary, DSPROpnd>;
1091
1092class SHRL_PH_DESC : SHLL_QB_R2_DESC_BASE<"shrl.ph", null_frag, immZExt4,
1093                                          NoItinerary, DSPROpnd, uimm4>;
1094
1095class SHRLV_PH_DESC : SHLL_QB_R3_DESC_BASE<"shrlv.ph", int_mips_shrl_ph,
1096                                           NoItinerary, DSPROpnd>;
1097
1098// Misc
1099class APPEND_DESC : APPEND_DESC_BASE<"append", int_mips_append, uimm5, immZExt5,
1100                                     NoItinerary>;
1101
1102class BALIGN_DESC : APPEND_DESC_BASE<"balign", int_mips_balign, uimm2, immZExt2,
1103                                     NoItinerary>;
1104
1105class PREPEND_DESC : APPEND_DESC_BASE<"prepend", int_mips_prepend, uimm5,
1106                                      immZExt5, NoItinerary>;
1107
1108// Pseudos.
1109def BPOSGE32_PSEUDO : BPOSGE32_PSEUDO_DESC_BASE<int_mips_bposge32,
1110                                                NoItinerary>, Uses<[DSPPos]>;
1111
1112// Instruction defs.
1113// MIPS DSP Rev 1
1114def ADDU_QB : DspMMRel, ADDU_QB_ENC, ADDU_QB_DESC;
1115def ADDU_S_QB : DspMMRel, ADDU_S_QB_ENC, ADDU_S_QB_DESC;
1116def SUBU_QB : DspMMRel, SUBU_QB_ENC, SUBU_QB_DESC;
1117def SUBU_S_QB : DspMMRel, SUBU_S_QB_ENC, SUBU_S_QB_DESC;
1118def ADDQ_PH : DspMMRel, ADDQ_PH_ENC, ADDQ_PH_DESC;
1119def ADDQ_S_PH : DspMMRel, ADDQ_S_PH_ENC, ADDQ_S_PH_DESC;
1120def SUBQ_PH : DspMMRel, SUBQ_PH_ENC, SUBQ_PH_DESC;
1121def SUBQ_S_PH : DspMMRel, SUBQ_S_PH_ENC, SUBQ_S_PH_DESC;
1122def ADDQ_S_W : DspMMRel, ADDQ_S_W_ENC, ADDQ_S_W_DESC;
1123def SUBQ_S_W : DspMMRel, SUBQ_S_W_ENC, SUBQ_S_W_DESC;
1124def ADDSC : DspMMRel, ADDSC_ENC, ADDSC_DESC;
1125def ADDWC : DspMMRel, ADDWC_ENC, ADDWC_DESC;
1126def MODSUB : DspMMRel, MODSUB_ENC, MODSUB_DESC;
1127def RADDU_W_QB : DspMMRel, RADDU_W_QB_ENC, RADDU_W_QB_DESC;
1128def ABSQ_S_PH : DspMMRel, ABSQ_S_PH_ENC, ABSQ_S_PH_DESC;
1129def ABSQ_S_W : DspMMRel, ABSQ_S_W_ENC, ABSQ_S_W_DESC;
1130def PRECRQ_QB_PH : DspMMRel, PRECRQ_QB_PH_ENC, PRECRQ_QB_PH_DESC;
1131def PRECRQ_PH_W : DspMMRel, PRECRQ_PH_W_ENC, PRECRQ_PH_W_DESC;
1132def PRECRQ_RS_PH_W : DspMMRel, PRECRQ_RS_PH_W_ENC, PRECRQ_RS_PH_W_DESC;
1133def PRECRQU_S_QB_PH : DspMMRel, PRECRQU_S_QB_PH_ENC, PRECRQU_S_QB_PH_DESC;
1134def PRECEQ_W_PHL : DspMMRel, PRECEQ_W_PHL_ENC, PRECEQ_W_PHL_DESC;
1135def PRECEQ_W_PHR : DspMMRel, PRECEQ_W_PHR_ENC, PRECEQ_W_PHR_DESC;
1136def PRECEQU_PH_QBL : DspMMRel, PRECEQU_PH_QBL_ENC, PRECEQU_PH_QBL_DESC;
1137def PRECEQU_PH_QBR : DspMMRel, PRECEQU_PH_QBR_ENC, PRECEQU_PH_QBR_DESC;
1138def PRECEQU_PH_QBLA : DspMMRel, PRECEQU_PH_QBLA_ENC, PRECEQU_PH_QBLA_DESC;
1139def PRECEQU_PH_QBRA : DspMMRel, PRECEQU_PH_QBRA_ENC, PRECEQU_PH_QBRA_DESC;
1140def PRECEU_PH_QBL : DspMMRel, PRECEU_PH_QBL_ENC, PRECEU_PH_QBL_DESC;
1141def PRECEU_PH_QBR : DspMMRel, PRECEU_PH_QBR_ENC, PRECEU_PH_QBR_DESC;
1142def PRECEU_PH_QBLA : DspMMRel, PRECEU_PH_QBLA_ENC, PRECEU_PH_QBLA_DESC;
1143def PRECEU_PH_QBRA : DspMMRel, PRECEU_PH_QBRA_ENC, PRECEU_PH_QBRA_DESC;
1144def SHLL_QB : DspMMRel, SHLL_QB_ENC, SHLL_QB_DESC;
1145def SHLLV_QB : DspMMRel, SHLLV_QB_ENC, SHLLV_QB_DESC;
1146def SHRL_QB : DspMMRel, SHRL_QB_ENC, SHRL_QB_DESC;
1147def SHRLV_QB : DspMMRel, SHRLV_QB_ENC, SHRLV_QB_DESC;
1148def SHLL_PH : DspMMRel, SHLL_PH_ENC, SHLL_PH_DESC;
1149def SHLLV_PH : DspMMRel, SHLLV_PH_ENC, SHLLV_PH_DESC;
1150def SHLL_S_PH : DspMMRel, SHLL_S_PH_ENC, SHLL_S_PH_DESC;
1151def SHLLV_S_PH : DspMMRel, SHLLV_S_PH_ENC, SHLLV_S_PH_DESC;
1152def SHRA_PH : DspMMRel, SHRA_PH_ENC, SHRA_PH_DESC;
1153def SHRAV_PH : DspMMRel, SHRAV_PH_ENC, SHRAV_PH_DESC;
1154def SHRA_R_PH : DspMMRel, SHRA_R_PH_ENC, SHRA_R_PH_DESC;
1155def SHRAV_R_PH : DspMMRel, SHRAV_R_PH_ENC, SHRAV_R_PH_DESC;
1156def SHLL_S_W : DspMMRel, SHLL_S_W_ENC, SHLL_S_W_DESC;
1157def SHLLV_S_W : DspMMRel, SHLLV_S_W_ENC, SHLLV_S_W_DESC;
1158def SHRA_R_W : DspMMRel, SHRA_R_W_ENC, SHRA_R_W_DESC;
1159def SHRAV_R_W : DspMMRel, SHRAV_R_W_ENC, SHRAV_R_W_DESC;
1160def MULEU_S_PH_QBL : DspMMRel, MULEU_S_PH_QBL_ENC, MULEU_S_PH_QBL_DESC;
1161def MULEU_S_PH_QBR : DspMMRel, MULEU_S_PH_QBR_ENC, MULEU_S_PH_QBR_DESC;
1162def MULEQ_S_W_PHL : DspMMRel, MULEQ_S_W_PHL_ENC, MULEQ_S_W_PHL_DESC;
1163def MULEQ_S_W_PHR : DspMMRel, MULEQ_S_W_PHR_ENC, MULEQ_S_W_PHR_DESC;
1164def MULQ_RS_PH : DspMMRel, MULQ_RS_PH_ENC, MULQ_RS_PH_DESC;
1165def MULSAQ_S_W_PH : DspMMRel, MULSAQ_S_W_PH_ENC, MULSAQ_S_W_PH_DESC;
1166def MAQ_S_W_PHL : DspMMRel, MAQ_S_W_PHL_ENC, MAQ_S_W_PHL_DESC;
1167def MAQ_S_W_PHR : DspMMRel, MAQ_S_W_PHR_ENC, MAQ_S_W_PHR_DESC;
1168def MAQ_SA_W_PHL : DspMMRel, MAQ_SA_W_PHL_ENC, MAQ_SA_W_PHL_DESC;
1169def MAQ_SA_W_PHR : DspMMRel, MAQ_SA_W_PHR_ENC, MAQ_SA_W_PHR_DESC;
1170def MFHI_DSP : DspMMRel, MFHI_ENC, MFHI_DESC;
1171def MFLO_DSP : DspMMRel, MFLO_ENC, MFLO_DESC;
1172def MTHI_DSP : DspMMRel, MTHI_ENC, MTHI_DESC;
1173def MTLO_DSP : DspMMRel, MTLO_ENC, MTLO_DESC;
1174def DPAU_H_QBL : DspMMRel, DPAU_H_QBL_ENC, DPAU_H_QBL_DESC;
1175def DPAU_H_QBR : DspMMRel, DPAU_H_QBR_ENC, DPAU_H_QBR_DESC;
1176def DPSU_H_QBL : DspMMRel, DPSU_H_QBL_ENC, DPSU_H_QBL_DESC;
1177def DPSU_H_QBR : DspMMRel, DPSU_H_QBR_ENC, DPSU_H_QBR_DESC;
1178def DPAQ_S_W_PH : DspMMRel, DPAQ_S_W_PH_ENC, DPAQ_S_W_PH_DESC;
1179def DPSQ_S_W_PH : DspMMRel, DPSQ_S_W_PH_ENC, DPSQ_S_W_PH_DESC;
1180def DPAQ_SA_L_W : DspMMRel, DPAQ_SA_L_W_ENC, DPAQ_SA_L_W_DESC;
1181def DPSQ_SA_L_W : DspMMRel, DPSQ_SA_L_W_ENC, DPSQ_SA_L_W_DESC;
1182def MULT_DSP : DspMMRel, MULT_DSP_ENC, MULT_DSP_DESC;
1183def MULTU_DSP : DspMMRel, MULTU_DSP_ENC, MULTU_DSP_DESC;
1184def MADD_DSP : DspMMRel, MADD_DSP_ENC, MADD_DSP_DESC;
1185def MADDU_DSP : DspMMRel, MADDU_DSP_ENC, MADDU_DSP_DESC;
1186def MSUB_DSP : DspMMRel, MSUB_DSP_ENC, MSUB_DSP_DESC;
1187def MSUBU_DSP : DspMMRel, MSUBU_DSP_ENC, MSUBU_DSP_DESC;
1188def CMPU_EQ_QB : DspMMRel, CMPU_EQ_QB_ENC, CMPU_EQ_QB_DESC;
1189def CMPU_LT_QB : DspMMRel, CMPU_LT_QB_ENC, CMPU_LT_QB_DESC;
1190def CMPU_LE_QB : DspMMRel, CMPU_LE_QB_ENC, CMPU_LE_QB_DESC;
1191def CMPGU_EQ_QB : DspMMRel, CMPGU_EQ_QB_ENC, CMPGU_EQ_QB_DESC;
1192def CMPGU_LT_QB : DspMMRel, CMPGU_LT_QB_ENC, CMPGU_LT_QB_DESC;
1193def CMPGU_LE_QB : DspMMRel, CMPGU_LE_QB_ENC, CMPGU_LE_QB_DESC;
1194def CMP_EQ_PH : DspMMRel, CMP_EQ_PH_ENC, CMP_EQ_PH_DESC;
1195def CMP_LT_PH : DspMMRel, CMP_LT_PH_ENC, CMP_LT_PH_DESC;
1196def CMP_LE_PH : DspMMRel, CMP_LE_PH_ENC, CMP_LE_PH_DESC;
1197def BITREV : DspMMRel, BITREV_ENC, BITREV_DESC;
1198def PACKRL_PH : DspMMRel, PACKRL_PH_ENC, PACKRL_PH_DESC;
1199def REPL_QB : DspMMRel, REPL_QB_ENC, REPL_QB_DESC;
1200def REPL_PH : DspMMRel, REPL_PH_ENC, REPL_PH_DESC;
1201def REPLV_QB : DspMMRel, REPLV_QB_ENC, REPLV_QB_DESC;
1202def REPLV_PH : DspMMRel, REPLV_PH_ENC, REPLV_PH_DESC;
1203def PICK_QB : DspMMRel, PICK_QB_ENC, PICK_QB_DESC;
1204def PICK_PH : DspMMRel, PICK_PH_ENC, PICK_PH_DESC;
1205def LWX : DspMMRel, LWX_ENC, LWX_DESC;
1206def LHX : DspMMRel, LHX_ENC, LHX_DESC;
1207def LBUX : DspMMRel, LBUX_ENC, LBUX_DESC;
1208let AdditionalPredicates = [NotInMicroMips] in {
1209  def BPOSGE32 : DspMMRel, BPOSGE32_ENC, BPOSGE32_DESC;
1210}
1211def INSV : DspMMRel, INSV_ENC, INSV_DESC;
1212def EXTP : DspMMRel, EXTP_ENC, EXTP_DESC;
1213def EXTPV : DspMMRel, EXTPV_ENC, EXTPV_DESC;
1214def EXTPDP : DspMMRel, EXTPDP_ENC, EXTPDP_DESC;
1215def EXTPDPV : DspMMRel, EXTPDPV_ENC, EXTPDPV_DESC;
1216def EXTR_W : DspMMRel, EXTR_W_ENC, EXTR_W_DESC;
1217def EXTRV_W : DspMMRel, EXTRV_W_ENC, EXTRV_W_DESC;
1218def EXTR_R_W : DspMMRel, EXTR_R_W_ENC, EXTR_R_W_DESC;
1219def EXTRV_R_W : DspMMRel, EXTRV_R_W_ENC, EXTRV_R_W_DESC;
1220def EXTR_RS_W : DspMMRel, EXTR_RS_W_ENC, EXTR_RS_W_DESC;
1221def EXTRV_RS_W : DspMMRel, EXTRV_RS_W_ENC, EXTRV_RS_W_DESC;
1222def EXTR_S_H : DspMMRel, EXTR_S_H_ENC, EXTR_S_H_DESC;
1223def EXTRV_S_H : DspMMRel, EXTRV_S_H_ENC, EXTRV_S_H_DESC;
1224def SHILO : DspMMRel, SHILO_ENC, SHILO_DESC;
1225def SHILOV : DspMMRel, SHILOV_ENC, SHILOV_DESC;
1226def MTHLIP : DspMMRel, MTHLIP_ENC, MTHLIP_DESC;
1227def RDDSP : DspMMRel, RDDSP_ENC, RDDSP_DESC;
1228let AdditionalPredicates = [NotInMicroMips] in {
1229  def WRDSP : WRDSP_ENC, WRDSP_DESC;
1230}
1231
1232// MIPS DSP Rev 2
1233def ADDU_PH : DspMMRel, ADDU_PH_ENC, ADDU_PH_DESC, ISA_DSPR2;
1234def ADDU_S_PH : DspMMRel, ADDU_S_PH_ENC, ADDU_S_PH_DESC, ISA_DSPR2;
1235def SUBU_PH : DspMMRel, SUBU_PH_ENC, SUBU_PH_DESC, ISA_DSPR2;
1236def SUBU_S_PH : DspMMRel, SUBU_S_PH_ENC, SUBU_S_PH_DESC, ISA_DSPR2;
1237def CMPGDU_EQ_QB : DspMMRel, CMPGDU_EQ_QB_ENC, CMPGDU_EQ_QB_DESC, ISA_DSPR2;
1238def CMPGDU_LT_QB : DspMMRel, CMPGDU_LT_QB_ENC, CMPGDU_LT_QB_DESC, ISA_DSPR2;
1239def CMPGDU_LE_QB : DspMMRel, CMPGDU_LE_QB_ENC, CMPGDU_LE_QB_DESC, ISA_DSPR2;
1240def ABSQ_S_QB : DspMMRel, ABSQ_S_QB_ENC, ABSQ_S_QB_DESC, ISA_DSPR2;
1241def ADDUH_QB : DspMMRel, ADDUH_QB_ENC, ADDUH_QB_DESC, ISA_DSPR2;
1242def ADDUH_R_QB : DspMMRel, ADDUH_R_QB_ENC, ADDUH_R_QB_DESC, ISA_DSPR2;
1243def SUBUH_QB : DspMMRel, SUBUH_QB_ENC, SUBUH_QB_DESC, ISA_DSPR2;
1244def SUBUH_R_QB : DspMMRel, SUBUH_R_QB_ENC, SUBUH_R_QB_DESC, ISA_DSPR2;
1245def ADDQH_PH : DspMMRel, ADDQH_PH_ENC, ADDQH_PH_DESC, ISA_DSPR2;
1246def ADDQH_R_PH : DspMMRel, ADDQH_R_PH_ENC, ADDQH_R_PH_DESC, ISA_DSPR2;
1247def SUBQH_PH : DspMMRel, SUBQH_PH_ENC, SUBQH_PH_DESC, ISA_DSPR2;
1248def SUBQH_R_PH : DspMMRel, SUBQH_R_PH_ENC, SUBQH_R_PH_DESC, ISA_DSPR2;
1249def ADDQH_W : DspMMRel, ADDQH_W_ENC, ADDQH_W_DESC, ISA_DSPR2;
1250def ADDQH_R_W : DspMMRel, ADDQH_R_W_ENC, ADDQH_R_W_DESC, ISA_DSPR2;
1251def SUBQH_W : DspMMRel, SUBQH_W_ENC, SUBQH_W_DESC, ISA_DSPR2;
1252def SUBQH_R_W : DspMMRel, SUBQH_R_W_ENC, SUBQH_R_W_DESC, ISA_DSPR2;
1253def MUL_PH : DspMMRel, MUL_PH_ENC, MUL_PH_DESC, ISA_DSPR2;
1254def MUL_S_PH : DspMMRel, MUL_S_PH_ENC, MUL_S_PH_DESC, ISA_DSPR2;
1255def MULQ_S_W : DspMMRel, MULQ_S_W_ENC, MULQ_S_W_DESC, ISA_DSPR2;
1256def MULQ_RS_W : DspMMRel, MULQ_RS_W_ENC, MULQ_RS_W_DESC, ISA_DSPR2;
1257def MULQ_S_PH : DspMMRel, MULQ_S_PH_ENC, MULQ_S_PH_DESC, ISA_DSPR2;
1258def DPA_W_PH : DspMMRel, DPA_W_PH_ENC, DPA_W_PH_DESC, ISA_DSPR2;
1259def DPS_W_PH : DspMMRel, DPS_W_PH_ENC, DPS_W_PH_DESC, ISA_DSPR2;
1260def DPAQX_S_W_PH : DspMMRel, DPAQX_S_W_PH_ENC, DPAQX_S_W_PH_DESC, ISA_DSPR2;
1261def DPAQX_SA_W_PH : DspMMRel, DPAQX_SA_W_PH_ENC, DPAQX_SA_W_PH_DESC, ISA_DSPR2;
1262def DPAX_W_PH : DspMMRel, DPAX_W_PH_ENC, DPAX_W_PH_DESC, ISA_DSPR2;
1263def DPSX_W_PH : DspMMRel, DPSX_W_PH_ENC, DPSX_W_PH_DESC, ISA_DSPR2;
1264def DPSQX_S_W_PH : DspMMRel, DPSQX_S_W_PH_ENC, DPSQX_S_W_PH_DESC, ISA_DSPR2;
1265def DPSQX_SA_W_PH : DspMMRel, DPSQX_SA_W_PH_ENC, DPSQX_SA_W_PH_DESC, ISA_DSPR2;
1266def MULSA_W_PH : DspMMRel, MULSA_W_PH_ENC, MULSA_W_PH_DESC, ISA_DSPR2;
1267def PRECR_QB_PH : DspMMRel, PRECR_QB_PH_ENC, PRECR_QB_PH_DESC, ISA_DSPR2;
1268def PRECR_SRA_PH_W : DspMMRel, PRECR_SRA_PH_W_ENC, PRECR_SRA_PH_W_DESC, ISA_DSPR2;
1269def PRECR_SRA_R_PH_W : DspMMRel, PRECR_SRA_R_PH_W_ENC, PRECR_SRA_R_PH_W_DESC, ISA_DSPR2;
1270def SHRA_QB : DspMMRel, SHRA_QB_ENC, SHRA_QB_DESC, ISA_DSPR2;
1271def SHRAV_QB : DspMMRel, SHRAV_QB_ENC, SHRAV_QB_DESC, ISA_DSPR2;
1272def SHRA_R_QB : DspMMRel, SHRA_R_QB_ENC, SHRA_R_QB_DESC, ISA_DSPR2;
1273def SHRAV_R_QB : DspMMRel, SHRAV_R_QB_ENC, SHRAV_R_QB_DESC, ISA_DSPR2;
1274def SHRL_PH : DspMMRel, SHRL_PH_ENC, SHRL_PH_DESC, ISA_DSPR2;
1275def SHRLV_PH : DspMMRel, SHRLV_PH_ENC, SHRLV_PH_DESC, ISA_DSPR2;
1276def APPEND : DspMMRel, APPEND_ENC, APPEND_DESC, ISA_DSPR2;
1277def BALIGN : DspMMRel, BALIGN_ENC, BALIGN_DESC, ISA_DSPR2;
1278def PREPEND : DspMMRel, PREPEND_ENC, PREPEND_DESC, ISA_DSPR2;
1279
1280// Pseudos.
1281let isPseudo = 1, isCodeGenOnly = 1, hasNoSchedulingInfo = 1 in {
1282  // Pseudo instructions for loading and storing accumulator registers.
1283  def LOAD_ACC64DSP  : Load<"", ACC64DSPOpnd>;
1284  def STORE_ACC64DSP : Store<"", ACC64DSPOpnd>;
1285
1286  // Pseudos for loading and storing ccond field of DSP control register.
1287  def LOAD_CCOND_DSP  : Load<"load_ccond_dsp", DSPCC>;
1288  def STORE_CCOND_DSP : Store<"store_ccond_dsp", DSPCC>;
1289}
1290
1291let DecoderNamespace = "MipsDSP", Arch = "dsp",
1292    ASEPredicate = [HasDSP] in {
1293  def LWDSP : Load<"lw", DSPROpnd, null_frag, II_LW>, DspMMRel, LW_FM<0x23>;
1294  def SWDSP : Store<"sw", DSPROpnd, null_frag, II_SW>, DspMMRel, LW_FM<0x2b>;
1295}
1296
1297// Pseudo CMP and PICK instructions.
1298class PseudoCMP<Instruction RealInst> :
1299  PseudoDSP<(outs DSPCC:$cmp), (ins DSPROpnd:$rs, DSPROpnd:$rt), []>,
1300  PseudoInstExpansion<(RealInst DSPROpnd:$rs, DSPROpnd:$rt)>, NeverHasSideEffects;
1301
1302class PseudoPICK<Instruction RealInst> :
1303  PseudoDSP<(outs DSPROpnd:$rd), (ins DSPCC:$cmp, DSPROpnd:$rs, DSPROpnd:$rt), []>,
1304  PseudoInstExpansion<(RealInst DSPROpnd:$rd, DSPROpnd:$rs, DSPROpnd:$rt)>,
1305  NeverHasSideEffects;
1306
1307def PseudoCMP_EQ_PH : PseudoCMP<CMP_EQ_PH>;
1308def PseudoCMP_LT_PH : PseudoCMP<CMP_LT_PH>;
1309def PseudoCMP_LE_PH : PseudoCMP<CMP_LE_PH>;
1310def PseudoCMPU_EQ_QB : PseudoCMP<CMPU_EQ_QB>;
1311def PseudoCMPU_LT_QB : PseudoCMP<CMPU_LT_QB>;
1312def PseudoCMPU_LE_QB : PseudoCMP<CMPU_LE_QB>;
1313
1314def PseudoPICK_PH : PseudoPICK<PICK_PH>;
1315def PseudoPICK_QB : PseudoPICK<PICK_QB>;
1316
1317def PseudoMTLOHI_DSP : PseudoMTLOHI<ACC64DSP, GPR32>;
1318
1319// Patterns.
1320class DSPPat<dag pattern, dag result, Predicate pred = HasDSP> :
1321  Pat<pattern, result>, Requires<[pred]>;
1322
1323class BitconvertPat<ValueType DstVT, ValueType SrcVT, RegisterClass DstRC,
1324                    RegisterClass SrcRC> :
1325   DSPPat<(DstVT (bitconvert (SrcVT SrcRC:$src))),
1326          (COPY_TO_REGCLASS SrcRC:$src, DstRC)>;
1327
1328def : BitconvertPat<i32, v2i16, GPR32, DSPR>;
1329def : BitconvertPat<i32, v4i8, GPR32, DSPR>;
1330def : BitconvertPat<v2i16, i32, DSPR, GPR32>;
1331def : BitconvertPat<v4i8, i32, DSPR, GPR32>;
1332def : BitconvertPat<f32, v2i16, FGR32, DSPR>;
1333def : BitconvertPat<f32, v4i8, FGR32, DSPR>;
1334def : BitconvertPat<v2i16, f32, DSPR, FGR32>;
1335def : BitconvertPat<v4i8, f32, DSPR, FGR32>;
1336
1337def : DSPPat<(v2i16 (load addr:$a)),
1338             (v2i16 (COPY_TO_REGCLASS (LW addr:$a), DSPR))>;
1339def : DSPPat<(v4i8 (load addr:$a)),
1340             (v4i8 (COPY_TO_REGCLASS (LW addr:$a), DSPR))>;
1341def : DSPPat<(store (v2i16 DSPR:$val), addr:$a),
1342             (SW (COPY_TO_REGCLASS DSPR:$val, GPR32), addr:$a)>;
1343def : DSPPat<(store (v4i8 DSPR:$val), addr:$a),
1344             (SW (COPY_TO_REGCLASS DSPR:$val, GPR32), addr:$a)>;
1345
1346// Binary operations.
1347class DSPBinPat<Instruction Inst, ValueType ValTy, SDPatternOperator Node,
1348                Predicate Pred = HasDSP> :
1349  DSPPat<(Node ValTy:$a, ValTy:$b), (Inst ValTy:$a, ValTy:$b), Pred>;
1350
1351def : DSPBinPat<ADDQ_PH, v2i16, int_mips_addq_ph>;
1352def : DSPBinPat<ADDQ_PH, v2i16, add>;
1353def : DSPBinPat<SUBQ_PH, v2i16, int_mips_subq_ph>;
1354def : DSPBinPat<SUBQ_PH, v2i16, sub>;
1355def : DSPBinPat<MUL_PH, v2i16, int_mips_mul_ph, HasDSPR2>;
1356def : DSPBinPat<MUL_PH, v2i16, mul, HasDSPR2>;
1357def : DSPBinPat<ADDU_QB, v4i8, int_mips_addu_qb>;
1358def : DSPBinPat<ADDU_QB, v4i8, add>;
1359def : DSPBinPat<SUBU_QB, v4i8, int_mips_subu_qb>;
1360def : DSPBinPat<SUBU_QB, v4i8, sub>;
1361def : DSPBinPat<ADDSC, i32, int_mips_addsc>;
1362def : DSPBinPat<ADDSC, i32, addc>;
1363def : DSPBinPat<ADDWC, i32, int_mips_addwc>;
1364def : DSPBinPat<ADDWC, i32, adde>;
1365
1366// Shift immediate patterns.
1367class DSPShiftPat<Instruction Inst, ValueType ValTy, SDPatternOperator Node,
1368                  SDPatternOperator Imm, Predicate Pred = HasDSP> :
1369  DSPPat<(Node ValTy:$a, Imm:$shamt), (Inst ValTy:$a, Imm:$shamt), Pred>;
1370
1371def : DSPShiftPat<SHLL_PH, v2i16, MipsSHLL_DSP, imm>;
1372def : DSPShiftPat<SHRA_PH, v2i16, MipsSHRA_DSP, imm>;
1373def : DSPShiftPat<SHRL_PH, v2i16, MipsSHRL_DSP, imm, HasDSPR2>;
1374def : DSPShiftPat<SHLL_PH, v2i16, int_mips_shll_ph, immZExt4>;
1375def : DSPShiftPat<SHRA_PH, v2i16, int_mips_shra_ph, immZExt4>;
1376def : DSPShiftPat<SHRL_PH, v2i16, int_mips_shrl_ph, immZExt4, HasDSPR2>;
1377def : DSPShiftPat<SHLL_QB, v4i8, MipsSHLL_DSP, imm>;
1378def : DSPShiftPat<SHRA_QB, v4i8, MipsSHRA_DSP, imm, HasDSPR2>;
1379def : DSPShiftPat<SHRL_QB, v4i8, MipsSHRL_DSP, imm>;
1380def : DSPShiftPat<SHLL_QB, v4i8, int_mips_shll_qb, immZExt3>;
1381def : DSPShiftPat<SHRA_QB, v4i8, int_mips_shra_qb, immZExt3, HasDSPR2>;
1382def : DSPShiftPat<SHRL_QB, v4i8, int_mips_shrl_qb, immZExt3>;
1383
1384// SETCC/SELECT_CC patterns.
1385class DSPSetCCPat<Instruction Cmp, Instruction Pick, ValueType ValTy,
1386                  CondCode CC> :
1387  DSPPat<(ValTy (MipsSETCC_DSP ValTy:$a, ValTy:$b, CC)),
1388         (ValTy (Pick (ValTy (Cmp ValTy:$a, ValTy:$b)),
1389                      (ValTy (COPY_TO_REGCLASS (ADDiu ZERO, -1), DSPR)),
1390                      (ValTy ZERO)))>;
1391
1392class DSPSetCCPatInv<Instruction Cmp, Instruction Pick, ValueType ValTy,
1393                     CondCode CC> :
1394  DSPPat<(ValTy (MipsSETCC_DSP ValTy:$a, ValTy:$b, CC)),
1395         (ValTy (Pick (ValTy (Cmp ValTy:$a, ValTy:$b)),
1396                      (ValTy ZERO),
1397                      (ValTy (COPY_TO_REGCLASS (ADDiu ZERO, -1), DSPR))))>;
1398
1399class DSPSelectCCPat<Instruction Cmp, Instruction Pick, ValueType ValTy,
1400                     CondCode CC> :
1401  DSPPat<(ValTy (MipsSELECT_CC_DSP ValTy:$a, ValTy:$b, ValTy:$c, ValTy:$d, CC)),
1402         (ValTy (Pick (ValTy (Cmp ValTy:$a, ValTy:$b)), $c, $d))>;
1403
1404class DSPSelectCCPatInv<Instruction Cmp, Instruction Pick, ValueType ValTy,
1405                        CondCode CC> :
1406  DSPPat<(ValTy (MipsSELECT_CC_DSP ValTy:$a, ValTy:$b, ValTy:$c, ValTy:$d, CC)),
1407         (ValTy (Pick (ValTy (Cmp ValTy:$a, ValTy:$b)), $d, $c))>;
1408
1409def : DSPSetCCPat<PseudoCMP_EQ_PH, PseudoPICK_PH, v2i16, SETEQ>;
1410def : DSPSetCCPat<PseudoCMP_LT_PH, PseudoPICK_PH, v2i16, SETLT>;
1411def : DSPSetCCPat<PseudoCMP_LE_PH, PseudoPICK_PH, v2i16, SETLE>;
1412def : DSPSetCCPatInv<PseudoCMP_EQ_PH, PseudoPICK_PH, v2i16, SETNE>;
1413def : DSPSetCCPatInv<PseudoCMP_LT_PH, PseudoPICK_PH, v2i16, SETGE>;
1414def : DSPSetCCPatInv<PseudoCMP_LE_PH, PseudoPICK_PH, v2i16, SETGT>;
1415def : DSPSetCCPat<PseudoCMPU_EQ_QB, PseudoPICK_QB, v4i8, SETEQ>;
1416def : DSPSetCCPat<PseudoCMPU_LT_QB, PseudoPICK_QB, v4i8, SETULT>;
1417def : DSPSetCCPat<PseudoCMPU_LE_QB, PseudoPICK_QB, v4i8, SETULE>;
1418def : DSPSetCCPatInv<PseudoCMPU_EQ_QB, PseudoPICK_QB, v4i8, SETNE>;
1419def : DSPSetCCPatInv<PseudoCMPU_LT_QB, PseudoPICK_QB, v4i8, SETUGE>;
1420def : DSPSetCCPatInv<PseudoCMPU_LE_QB, PseudoPICK_QB, v4i8, SETUGT>;
1421
1422def : DSPSelectCCPat<PseudoCMP_EQ_PH, PseudoPICK_PH, v2i16, SETEQ>;
1423def : DSPSelectCCPat<PseudoCMP_LT_PH, PseudoPICK_PH, v2i16, SETLT>;
1424def : DSPSelectCCPat<PseudoCMP_LE_PH, PseudoPICK_PH, v2i16, SETLE>;
1425def : DSPSelectCCPatInv<PseudoCMP_EQ_PH, PseudoPICK_PH, v2i16, SETNE>;
1426def : DSPSelectCCPatInv<PseudoCMP_LT_PH, PseudoPICK_PH, v2i16, SETGE>;
1427def : DSPSelectCCPatInv<PseudoCMP_LE_PH, PseudoPICK_PH, v2i16, SETGT>;
1428def : DSPSelectCCPat<PseudoCMPU_EQ_QB, PseudoPICK_QB, v4i8, SETEQ>;
1429def : DSPSelectCCPat<PseudoCMPU_LT_QB, PseudoPICK_QB, v4i8, SETULT>;
1430def : DSPSelectCCPat<PseudoCMPU_LE_QB, PseudoPICK_QB, v4i8, SETULE>;
1431def : DSPSelectCCPatInv<PseudoCMPU_EQ_QB, PseudoPICK_QB, v4i8, SETNE>;
1432def : DSPSelectCCPatInv<PseudoCMPU_LT_QB, PseudoPICK_QB, v4i8, SETUGE>;
1433def : DSPSelectCCPatInv<PseudoCMPU_LE_QB, PseudoPICK_QB, v4i8, SETUGT>;
1434
1435// Extr patterns.
1436class EXTR_W_TY1_R2_Pat<SDPatternOperator OpNode, Instruction Instr> :
1437  DSPPat<(i32 (OpNode GPR32:$rs, ACC64DSP:$ac)),
1438         (Instr ACC64DSP:$ac, GPR32:$rs)>;
1439
1440class EXTR_W_TY1_R1_Pat<SDPatternOperator OpNode, Instruction Instr> :
1441  DSPPat<(i32 (OpNode immZExt5:$shift, ACC64DSP:$ac)),
1442         (Instr ACC64DSP:$ac, immZExt5:$shift)>;
1443
1444def : EXTR_W_TY1_R1_Pat<MipsEXTP, EXTP>;
1445def : EXTR_W_TY1_R2_Pat<MipsEXTP, EXTPV>;
1446def : EXTR_W_TY1_R1_Pat<MipsEXTPDP, EXTPDP>;
1447def : EXTR_W_TY1_R2_Pat<MipsEXTPDP, EXTPDPV>;
1448def : EXTR_W_TY1_R1_Pat<MipsEXTR_W, EXTR_W>;
1449def : EXTR_W_TY1_R2_Pat<MipsEXTR_W, EXTRV_W>;
1450def : EXTR_W_TY1_R1_Pat<MipsEXTR_R_W, EXTR_R_W>;
1451def : EXTR_W_TY1_R2_Pat<MipsEXTR_R_W, EXTRV_R_W>;
1452def : EXTR_W_TY1_R1_Pat<MipsEXTR_RS_W, EXTR_RS_W>;
1453def : EXTR_W_TY1_R2_Pat<MipsEXTR_RS_W, EXTRV_RS_W>;
1454def : EXTR_W_TY1_R1_Pat<MipsEXTR_S_H, EXTR_S_H>;
1455def : EXTR_W_TY1_R2_Pat<MipsEXTR_S_H, EXTRV_S_H>;
1456
1457// Indexed load patterns.
1458class IndexedLoadPat<SDPatternOperator LoadNode, Instruction Instr> :
1459  DSPPat<(i32 (LoadNode (add i32:$base, i32:$index))),
1460         (Instr i32:$base, i32:$index)>;
1461
1462let AddedComplexity = 20 in {
1463  def : IndexedLoadPat<zextloadi8, LBUX>;
1464  def : IndexedLoadPat<sextloadi16, LHX>;
1465  def : IndexedLoadPat<load, LWX>;
1466}
1467
1468// Instruction alias.
1469let AdditionalPredicates = [NotInMicroMips] in {
1470  def : DSPInstAlias<"wrdsp $rt", (WRDSP GPR32Opnd:$rt, 0x1F), 1>;
1471}
1472