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