4279b6fbe3052284271a3b9acecfc3317475ec5f
[oota-llvm.git] / lib / Target / Mips / MipsDSPInstrFormats.td
1 //===- MipsDSPInstrFormats.td - Mips Instruction Formats ---*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 class DspMMRel;
11
12 def Dsp2MicroMips : InstrMapping {
13   let FilterClass = "DspMMRel";
14   // Instructions with the same BaseOpcode and isNVStore values form a row.
15   let RowFields = ["BaseOpcode"];
16   // Instructions with the same predicate sense form a column.
17   let ColFields = ["Arch"];
18   // The key column is the unpredicated instructions.
19   let KeyCol = ["dsp"];
20   // Value columns are PredSense=true and PredSense=false
21   let ValueCols = [["dsp"], ["mmdsp"]];
22 }
23
24 def HasDSP : Predicate<"Subtarget->hasDSP()">,
25              AssemblerPredicate<"FeatureDSP">;
26 def HasDSPR2 : Predicate<"Subtarget->hasDSPR2()">,
27                AssemblerPredicate<"FeatureDSPR2">;
28 def HasDSPR3 : Predicate<"Subtarget->hasDSPR3()">,
29                AssemblerPredicate<"FeatureDSPR3">;
30
31 class ISA_DSPR2 {
32   list<Predicate> InsnPredicates = [HasDSPR2];
33 }
34
35 // Fields.
36 class Field6<bits<6> val> {
37   bits<6> V = val;
38 }
39
40 def SPECIAL3_OPCODE : Field6<0b011111>;
41 def REGIMM_OPCODE : Field6<0b000001>;
42
43 class DSPInst<string opstr = "">
44     : MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther> {
45   let Predicates = [HasDSP];
46   string BaseOpcode = opstr;
47   string Arch = "dsp";
48 }
49
50 class PseudoDSP<dag outs, dag ins, list<dag> pattern,
51                 InstrItinClass itin = IIPseudo>:
52   MipsPseudo<outs, ins, pattern, itin> {
53   let Predicates = [HasDSP];
54 }
55
56 // ADDU.QB sub-class format.
57 class ADDU_QB_FMT<bits<5> op> : DSPInst {
58   bits<5> rd;
59   bits<5> rs;
60   bits<5> rt;
61
62   let Opcode = SPECIAL3_OPCODE.V;
63
64   let Inst{25-21} = rs;
65   let Inst{20-16} = rt;
66   let Inst{15-11} = rd;
67   let Inst{10-6}  = op;
68   let Inst{5-0}   = 0b010000;
69 }
70
71 class RADDU_W_QB_FMT<bits<5> op> : DSPInst {
72   bits<5> rd;
73   bits<5> rs;
74
75   let Opcode = SPECIAL3_OPCODE.V;
76
77   let Inst{25-21} = rs;
78   let Inst{20-16} = 0;
79   let Inst{15-11} = rd;
80   let Inst{10-6}  = op;
81   let Inst{5-0}   = 0b010000;
82 }
83
84 // CMPU.EQ.QB sub-class format.
85 class CMP_EQ_QB_R2_FMT<bits<5> op> : DSPInst {
86   bits<5> rs;
87   bits<5> rt;
88
89   let Opcode = SPECIAL3_OPCODE.V;
90
91   let Inst{25-21} = rs;
92   let Inst{20-16} = rt;
93   let Inst{15-11} = 0;
94   let Inst{10-6}  = op;
95   let Inst{5-0}   = 0b010001;
96 }
97
98 class CMP_EQ_QB_R3_FMT<bits<5> op> : DSPInst {
99   bits<5> rs;
100   bits<5> rt;
101   bits<5> rd;
102
103   let Opcode = SPECIAL3_OPCODE.V;
104
105   let Inst{25-21} = rs;
106   let Inst{20-16} = rt;
107   let Inst{15-11} = rd;
108   let Inst{10-6}  = op;
109   let Inst{5-0}   = 0b010001;
110 }
111
112 class PRECR_SRA_PH_W_FMT<bits<5> op> : DSPInst {
113   bits<5> rs;
114   bits<5> rt;
115   bits<5> sa;
116
117   let Opcode = SPECIAL3_OPCODE.V;
118
119   let Inst{25-21} = rs;
120   let Inst{20-16} = rt;
121   let Inst{15-11} = sa;
122   let Inst{10-6}  = op;
123   let Inst{5-0}   = 0b010001;
124 }
125
126 // ABSQ_S.PH sub-class format.
127 class ABSQ_S_PH_R2_FMT<bits<5> op> : DSPInst {
128   bits<5> rd;
129   bits<5> rt;
130
131   let Opcode = SPECIAL3_OPCODE.V;
132
133   let Inst{25-21} = 0;
134   let Inst{20-16} = rt;
135   let Inst{15-11} = rd;
136   let Inst{10-6}  = op;
137   let Inst{5-0}   = 0b010010;
138 }
139
140
141 class REPL_FMT<bits<5> op> : DSPInst {
142   bits<5> rd;
143   bits<10> imm;
144
145   let Opcode = SPECIAL3_OPCODE.V;
146
147   let Inst{25-16} = imm;
148   let Inst{15-11} = rd;
149   let Inst{10-6}  = op;
150   let Inst{5-0}   = 0b010010;
151 }
152
153 // SHLL.QB sub-class format.
154 class SHLL_QB_FMT<bits<5> op> : DSPInst {
155   bits<5> rd;
156   bits<5> rt;
157   bits<5> rs_sa;
158
159   let Opcode = SPECIAL3_OPCODE.V;
160
161   let Inst{25-21} = rs_sa;
162   let Inst{20-16} = rt;
163   let Inst{15-11} = rd;
164   let Inst{10-6}  = op;
165   let Inst{5-0}   = 0b010011;
166 }
167
168 // LX sub-class format.
169 class LX_FMT<bits<5> op> : DSPInst {
170   bits<5> rd;
171   bits<5> base;
172   bits<5> index;
173
174   let Opcode = SPECIAL3_OPCODE.V;
175
176   let Inst{25-21} = base;
177   let Inst{20-16} = index;
178   let Inst{15-11} = rd;
179   let Inst{10-6}  = op;
180   let Inst{5-0} = 0b001010;
181 }
182
183 // ADDUH.QB sub-class format.
184 class ADDUH_QB_FMT<bits<5> op> : DSPInst {
185   bits<5> rd;
186   bits<5> rs;
187   bits<5> rt;
188
189   let Opcode = SPECIAL3_OPCODE.V;
190
191   let Inst{25-21} = rs;
192   let Inst{20-16} = rt;
193   let Inst{15-11} = rd;
194   let Inst{10-6} = op;
195   let Inst{5-0} = 0b011000;
196 }
197
198 // APPEND sub-class format.
199 class APPEND_FMT<bits<5> op> : DSPInst {
200   bits<5> rt;
201   bits<5> rs;
202   bits<5> sa;
203
204   let Opcode = SPECIAL3_OPCODE.V;
205
206   let Inst{25-21} = rs;
207   let Inst{20-16} = rt;
208   let Inst{15-11} = sa;
209   let Inst{10-6} = op;
210   let Inst{5-0} = 0b110001;
211 }
212
213 // DPA.W.PH sub-class format.
214 class DPA_W_PH_FMT<bits<5> op> : DSPInst {
215   bits<2> ac;
216   bits<5> rs;
217   bits<5> rt;
218
219   let Opcode = SPECIAL3_OPCODE.V;
220
221   let Inst{25-21} = rs;
222   let Inst{20-16} = rt;
223   let Inst{15-13} = 0;
224   let Inst{12-11} = ac;
225   let Inst{10-6}  = op;
226   let Inst{5-0} = 0b110000;
227 }
228
229 // MULT sub-class format.
230 class MULT_FMT<bits<6> opcode, bits<6> funct> : DSPInst {
231   bits<2> ac;
232   bits<5> rs;
233   bits<5> rt;
234
235   let Opcode = opcode;
236
237   let Inst{25-21} = rs;
238   let Inst{20-16} = rt;
239   let Inst{15-13} = 0;
240   let Inst{12-11} = ac;
241   let Inst{10-6}  = 0;
242   let Inst{5-0} = funct;
243 }
244
245 // MFHI sub-class format.
246 class MFHI_FMT<bits<6> funct> : DSPInst {
247   bits<5> rd;
248   bits<2> ac;
249
250   let Inst{31-26} = 0;
251   let Inst{25-23} = 0;
252   let Inst{22-21} = ac;
253   let Inst{20-16} = 0;
254   let Inst{15-11} = rd;
255   let Inst{10-6} = 0;
256   let Inst{5-0} = funct;
257 }
258
259 // MTHI sub-class format.
260 class MTHI_FMT<bits<6> funct> : DSPInst {
261   bits<5> rs;
262   bits<2> ac;
263
264   let Inst{31-26} = 0;
265   let Inst{25-21} = rs;
266   let Inst{20-13} = 0;
267   let Inst{12-11} = ac;
268   let Inst{10-6} = 0;
269   let Inst{5-0} = funct;
270 }
271
272 // EXTR.W sub-class format (type 1).
273 class EXTR_W_TY1_FMT<bits<5> op> : DSPInst {
274   bits<5> rt;
275   bits<2> ac;
276   bits<5> shift_rs;
277
278   let Opcode = SPECIAL3_OPCODE.V;
279
280   let Inst{25-21} = shift_rs;
281   let Inst{20-16} = rt;
282   let Inst{15-13} = 0;
283   let Inst{12-11} = ac;
284   let Inst{10-6} = op;
285   let Inst{5-0} = 0b111000;
286 }
287
288 // SHILO sub-class format.
289 class SHILO_R1_FMT<bits<5> op> : DSPInst {
290   bits<2> ac;
291   bits<6> shift;
292
293   let Opcode = SPECIAL3_OPCODE.V;
294
295   let Inst{25-20} = shift;
296   let Inst{19-13} = 0;
297   let Inst{12-11} = ac;
298   let Inst{10-6} = op;
299   let Inst{5-0} = 0b111000;
300 }
301
302 class SHILO_R2_FMT<bits<5> op> : DSPInst {
303   bits<2> ac;
304   bits<5> rs;
305
306   let Opcode = SPECIAL3_OPCODE.V;
307
308   let Inst{25-21} = rs;
309   let Inst{20-13} = 0;
310   let Inst{12-11} = ac;
311   let Inst{10-6} = op;
312   let Inst{5-0} = 0b111000;
313 }
314
315 class RDDSP_FMT<bits<5> op> : DSPInst {
316   bits<5> rd;
317   bits<10> mask;
318
319   let Opcode = SPECIAL3_OPCODE.V;
320
321   let Inst{25-16} = mask;
322   let Inst{15-11} = rd;
323   let Inst{10-6} = op;
324   let Inst{5-0} = 0b111000;
325 }
326
327 class WRDSP_FMT<bits<5> op> : DSPInst {
328   bits<5> rs;
329   bits<10> mask;
330
331   let Opcode = SPECIAL3_OPCODE.V;
332
333   let Inst{25-21} = rs;
334   let Inst{20-11} = mask;
335   let Inst{10-6} = op;
336   let Inst{5-0} = 0b111000;
337 }
338
339 class BPOSGE32_FMT<bits<5> op> : DSPInst {
340   bits<16> offset;
341
342   let Opcode = REGIMM_OPCODE.V;
343
344   let Inst{25-21} = 0;
345   let Inst{20-16} = op;
346   let Inst{15-0} = offset;
347 }
348
349 // INSV sub-class format.
350 class INSV_FMT<bits<6> op> : DSPInst {
351   bits<5> rt;
352   bits<5> rs;
353
354   let Opcode = SPECIAL3_OPCODE.V;
355
356   let Inst{25-21} = rs;
357   let Inst{20-16} = rt;
358   let Inst{15-6} = 0;
359   let Inst{5-0} = op;
360 }