blob: 54cebcdecd61a35b3f5bf23871ea04baff34a5d4 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- PowerPCInstrFormats.td - PowerPC Instruction Formats --*- tablegen -*-=//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// PowerPC instruction formats
13
Evan Chengb783fa32007-07-19 01:14:50 +000014class I<bits<6> opcode, dag OOL, dag IOL, string asmstr, InstrItinClass itin>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015 : Instruction {
16 field bits<32> Inst;
17
18 bit PPC64 = 0; // Default value, override with isPPC64
19
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020 let Namespace = "PPC";
21 let Inst{0-5} = opcode;
Evan Chengb783fa32007-07-19 01:14:50 +000022 let OutOperandList = OOL;
23 let InOperandList = IOL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024 let AsmString = asmstr;
25 let Itinerary = itin;
26
27 /// These fields correspond to the fields in PPCInstrInfo.h. Any changes to
28 /// these must be reflected there! See comments there for what these are.
29 bits<1> PPC970_First = 0;
30 bits<1> PPC970_Single = 0;
31 bits<1> PPC970_Cracked = 0;
32 bits<3> PPC970_Unit = 0;
33}
34
35class PPC970_DGroup_First { bits<1> PPC970_First = 1; }
36class PPC970_DGroup_Single { bits<1> PPC970_Single = 1; }
37class PPC970_DGroup_Cracked { bits<1> PPC970_Cracked = 1; }
38class PPC970_MicroCode;
39
40class PPC970_Unit_Pseudo { bits<3> PPC970_Unit = 0; }
41class PPC970_Unit_FXU { bits<3> PPC970_Unit = 1; }
42class PPC970_Unit_LSU { bits<3> PPC970_Unit = 2; }
43class PPC970_Unit_FPU { bits<3> PPC970_Unit = 3; }
44class PPC970_Unit_CRU { bits<3> PPC970_Unit = 4; }
45class PPC970_Unit_VALU { bits<3> PPC970_Unit = 5; }
46class PPC970_Unit_VPERM { bits<3> PPC970_Unit = 6; }
47class PPC970_Unit_BRU { bits<3> PPC970_Unit = 7; }
48
49
50// 1.7.1 I-Form
Evan Chengb783fa32007-07-19 01:14:50 +000051class IForm<bits<6> opcode, bit aa, bit lk, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +000053 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000054 let Pattern = pattern;
55 bits<24> LI;
56
57 let Inst{6-29} = LI;
58 let Inst{30} = aa;
59 let Inst{31} = lk;
60}
61
62// 1.7.2 B-Form
Evan Chengb783fa32007-07-19 01:14:50 +000063class BForm<bits<6> opcode, bit aa, bit lk, dag OOL, dag IOL, string asmstr>
64 : I<opcode, OOL, IOL, asmstr, BrB> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000065 bits<7> BIBO; // 2 bits of BI and 5 bits of BO.
66 bits<3> CR;
67 bits<14> BD;
68
69 bits<5> BI;
70 let BI{0-1} = BIBO{5-6};
71 let BI{2-4} = CR{0-2};
72
73 let Inst{6-10} = BIBO{4-0};
74 let Inst{11-15} = BI;
75 let Inst{16-29} = BD;
76 let Inst{30} = aa;
77 let Inst{31} = lk;
78}
79
80
81// 1.7.4 D-Form
Evan Chengb783fa32007-07-19 01:14:50 +000082class DForm_base<bits<6> opcode, dag OOL, dag IOL, string asmstr,
83 InstrItinClass itin, list<dag> pattern>
84 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085 bits<5> A;
86 bits<5> B;
87 bits<16> C;
88
89 let Pattern = pattern;
90
91 let Inst{6-10} = A;
92 let Inst{11-15} = B;
93 let Inst{16-31} = C;
94}
95
Evan Chengb783fa32007-07-19 01:14:50 +000096class DForm_1<bits<6> opcode, dag OOL, dag IOL, string asmstr,
97 InstrItinClass itin, list<dag> pattern>
98 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000099 bits<5> A;
100 bits<16> C;
101 bits<5> B;
102
103 let Pattern = pattern;
104
105 let Inst{6-10} = A;
106 let Inst{11-15} = B;
107 let Inst{16-31} = C;
108}
109
Evan Chengb783fa32007-07-19 01:14:50 +0000110class DForm_2<bits<6> opcode, dag OOL, dag IOL, string asmstr,
111 InstrItinClass itin, list<dag> pattern>
112 : DForm_base<opcode, OOL, IOL, asmstr, itin, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000113
Evan Chengb783fa32007-07-19 01:14:50 +0000114class DForm_2_r0<bits<6> opcode, dag OOL, dag IOL, string asmstr,
115 InstrItinClass itin, list<dag> pattern>
116 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117 bits<5> A;
118 bits<16> B;
119
120 let Pattern = pattern;
121
122 let Inst{6-10} = A;
123 let Inst{11-15} = 0;
124 let Inst{16-31} = B;
125}
126
Evan Chengb783fa32007-07-19 01:14:50 +0000127class DForm_4<bits<6> opcode, dag OOL, dag IOL, string asmstr,
128 InstrItinClass itin, list<dag> pattern>
129 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130 bits<5> B;
131 bits<5> A;
132 bits<16> C;
133
134 let Pattern = pattern;
135
136 let Inst{6-10} = A;
137 let Inst{11-15} = B;
138 let Inst{16-31} = C;
139}
140
Evan Chengb783fa32007-07-19 01:14:50 +0000141class DForm_4_zero<bits<6> opcode, dag OOL, dag IOL, string asmstr,
142 InstrItinClass itin, list<dag> pattern>
143 : DForm_1<opcode, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144 let A = 0;
145 let B = 0;
146 let C = 0;
147}
148
Evan Chengb783fa32007-07-19 01:14:50 +0000149class DForm_5<bits<6> opcode, dag OOL, dag IOL, string asmstr,
150 InstrItinClass itin>
151 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152 bits<3> BF;
153 bits<1> L;
154 bits<5> RA;
155 bits<16> I;
156
157 let Inst{6-8} = BF;
158 let Inst{9} = 0;
159 let Inst{10} = L;
160 let Inst{11-15} = RA;
161 let Inst{16-31} = I;
162}
163
Evan Chengb783fa32007-07-19 01:14:50 +0000164class DForm_5_ext<bits<6> opcode, dag OOL, dag IOL, string asmstr,
165 InstrItinClass itin>
166 : DForm_5<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 let L = PPC64;
168}
169
Evan Chengb783fa32007-07-19 01:14:50 +0000170class DForm_6<bits<6> opcode, dag OOL, dag IOL, string asmstr,
171 InstrItinClass itin>
172 : DForm_5<opcode, OOL, IOL, asmstr, itin>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173
Evan Chengb783fa32007-07-19 01:14:50 +0000174class DForm_6_ext<bits<6> opcode, dag OOL, dag IOL, string asmstr,
175 InstrItinClass itin>
176 : DForm_6<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 let L = PPC64;
178}
179
180
181// 1.7.5 DS-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000182class DSForm_1<bits<6> opcode, bits<2> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000184 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 bits<5> RST;
186 bits<14> DS;
187 bits<5> RA;
188
189 let Pattern = pattern;
190
191 let Inst{6-10} = RST;
192 let Inst{11-15} = RA;
193 let Inst{16-29} = DS;
194 let Inst{30-31} = xo;
195}
196
197// 1.7.6 X-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000198class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000200 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 bits<5> RST;
202 bits<5> A;
203 bits<5> B;
204
205 let Pattern = pattern;
206
207 bit RC = 0; // set by isDOT
208
209 let Inst{6-10} = RST;
210 let Inst{11-15} = A;
211 let Inst{16-20} = B;
212 let Inst{21-30} = xo;
213 let Inst{31} = RC;
214}
215
216// This is the same as XForm_base_r3xo, but the first two operands are swapped
217// when code is emitted.
218class XForm_base_r3xo_swapped
Evan Chengb783fa32007-07-19 01:14:50 +0000219 <bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000221 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222 bits<5> A;
223 bits<5> RST;
224 bits<5> B;
225
226 bit RC = 0; // set by isDOT
227
228 let Inst{6-10} = RST;
229 let Inst{11-15} = A;
230 let Inst{16-20} = B;
231 let Inst{21-30} = xo;
232 let Inst{31} = RC;
233}
234
235
Evan Chengb783fa32007-07-19 01:14:50 +0000236class XForm_1<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000237 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000238 : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239
Evan Chengb783fa32007-07-19 01:14:50 +0000240class XForm_6<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000242 : XForm_base_r3xo_swapped<opcode, xo, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243 let Pattern = pattern;
244}
245
Evan Chengb783fa32007-07-19 01:14:50 +0000246class XForm_8<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000248 : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249
Evan Chengb783fa32007-07-19 01:14:50 +0000250class XForm_10<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000251 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000252 : XForm_base_r3xo_swapped<opcode, xo, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253 let Pattern = pattern;
254}
255
Evan Chengb783fa32007-07-19 01:14:50 +0000256class XForm_11<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000258 : XForm_base_r3xo_swapped<opcode, xo, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259 let B = 0;
260 let Pattern = pattern;
261}
262
Evan Chengb783fa32007-07-19 01:14:50 +0000263class XForm_16<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000265 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 bits<3> BF;
267 bits<1> L;
268 bits<5> RA;
269 bits<5> RB;
270
271 let Inst{6-8} = BF;
272 let Inst{9} = 0;
273 let Inst{10} = L;
274 let Inst{11-15} = RA;
275 let Inst{16-20} = RB;
276 let Inst{21-30} = xo;
277 let Inst{31} = 0;
278}
279
Evan Chengb783fa32007-07-19 01:14:50 +0000280class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000282 : XForm_16<opcode, xo, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283 let L = PPC64;
284}
285
Evan Chengb783fa32007-07-19 01:14:50 +0000286class XForm_17<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000288 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289 bits<3> BF;
290 bits<5> FRA;
291 bits<5> FRB;
292
293 let Inst{6-8} = BF;
294 let Inst{9-10} = 0;
295 let Inst{11-15} = FRA;
296 let Inst{16-20} = FRB;
297 let Inst{21-30} = xo;
298 let Inst{31} = 0;
299}
300
Nate Begemanf46776e2008-08-11 17:36:31 +0000301class XForm_24<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
302 InstrItinClass itin, list<dag> pattern>
303 : I<opcode, OOL, IOL, asmstr, itin> {
304 let Pattern = pattern;
305 let Inst{6-10} = 31;
306 let Inst{11-15} = 0;
307 let Inst{16-20} = 0;
308 let Inst{21-30} = xo;
309 let Inst{31} = 0;
310}
311
Dale Johannesen8d4de232008-08-22 17:20:54 +0000312class XForm_24_sync<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
313 string asmstr, InstrItinClass itin, list<dag> pattern>
314 : I<opcode, OOL, IOL, asmstr, itin> {
315 let Pattern = pattern;
316 let Inst{6-10} = 0;
317 let Inst{11-15} = 0;
318 let Inst{16-20} = 0;
319 let Inst{21-30} = xo;
320 let Inst{31} = 0;
321}
322
Evan Chengb783fa32007-07-19 01:14:50 +0000323class XForm_25<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000325 : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326}
327
Evan Chengb783fa32007-07-19 01:14:50 +0000328class XForm_26<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000330 : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 let A = 0;
332}
333
Evan Chengb783fa32007-07-19 01:14:50 +0000334class XForm_28<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000336 : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337}
338
Dale Johannesen3d8578b2007-10-10 01:01:31 +0000339// This is used for MFFS, MTFSB0, MTFSB1. 42 is arbitrary; this series of
340// numbers presumably relates to some document, but I haven't found it.
341class XForm_42<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
342 InstrItinClass itin, list<dag> pattern>
343 : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
344 let Pattern = pattern;
345
346 bit RC = 0; // set by isDOT
347
348 let Inst{6-10} = RST;
349 let Inst{11-20} = 0;
350 let Inst{21-30} = xo;
351 let Inst{31} = RC;
352}
353class XForm_43<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
354 InstrItinClass itin, list<dag> pattern>
355 : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
356 let Pattern = pattern;
357 bits<5> FM;
358
359 bit RC = 0; // set by isDOT
360
361 let Inst{6-10} = FM;
362 let Inst{11-20} = 0;
363 let Inst{21-30} = xo;
364 let Inst{31} = RC;
365}
366
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367// DCB_Form - Form X instruction, used for dcb* instructions.
Evan Chengb783fa32007-07-19 01:14:50 +0000368class DCB_Form<bits<10> xo, bits<5> immfield, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000370 : I<31, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371 bits<5> A;
372 bits<5> B;
373
374 let Pattern = pattern;
375
376 let Inst{6-10} = immfield;
377 let Inst{11-15} = A;
378 let Inst{16-20} = B;
379 let Inst{21-30} = xo;
380 let Inst{31} = 0;
381}
382
383
384// DSS_Form - Form X instruction, used for altivec dss* instructions.
Evan Chengb783fa32007-07-19 01:14:50 +0000385class DSS_Form<bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000387 : I<31, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 bits<1> T;
389 bits<2> STRM;
390 bits<5> A;
391 bits<5> B;
392
393 let Pattern = pattern;
394
395 let Inst{6} = T;
396 let Inst{7-8} = 0;
397 let Inst{9-10} = STRM;
398 let Inst{11-15} = A;
399 let Inst{16-20} = B;
400 let Inst{21-30} = xo;
401 let Inst{31} = 0;
402}
403
404// 1.7.7 XL-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000405class XLForm_1<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000407 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408 bits<5> CRD;
409 bits<5> CRA;
410 bits<5> CRB;
411
412 let Pattern = pattern;
413
414 let Inst{6-10} = CRD;
415 let Inst{11-15} = CRA;
416 let Inst{16-20} = CRB;
417 let Inst{21-30} = xo;
418 let Inst{31} = 0;
419}
420
Evan Chengb783fa32007-07-19 01:14:50 +0000421class XLForm_1_ext<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000423 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424 bits<5> CRD;
425
426 let Pattern = pattern;
427
428 let Inst{6-10} = CRD;
429 let Inst{11-15} = CRD;
430 let Inst{16-20} = CRD;
431 let Inst{21-30} = xo;
432 let Inst{31} = 0;
433}
434
Evan Chengb783fa32007-07-19 01:14:50 +0000435class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000437 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 bits<5> BO;
439 bits<5> BI;
440 bits<2> BH;
441
442 let Pattern = pattern;
443
444 let Inst{6-10} = BO;
445 let Inst{11-15} = BI;
446 let Inst{16-18} = 0;
447 let Inst{19-20} = BH;
448 let Inst{21-30} = xo;
449 let Inst{31} = lk;
450}
451
452class XLForm_2_br<bits<6> opcode, bits<10> xo, bit lk,
Evan Chengb783fa32007-07-19 01:14:50 +0000453 dag OOL, dag IOL, string asmstr, InstrItinClass itin, list<dag> pattern>
454 : XLForm_2<opcode, xo, lk, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000455 bits<7> BIBO; // 2 bits of BI and 5 bits of BO.
456 bits<3> CR;
457
458 let BO = BIBO{2-6};
459 let BI{0-1} = BIBO{0-1};
460 let BI{2-4} = CR;
461 let BH = 0;
462}
463
464
465class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo, bits<5> bi, bit lk,
Evan Chengb783fa32007-07-19 01:14:50 +0000466 dag OOL, dag IOL, string asmstr, InstrItinClass itin, list<dag> pattern>
467 : XLForm_2<opcode, xo, lk, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468 let BO = bo;
469 let BI = bi;
470 let BH = 0;
471}
472
Evan Chengb783fa32007-07-19 01:14:50 +0000473class XLForm_3<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000474 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000475 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 bits<3> BF;
477 bits<3> BFA;
478
479 let Inst{6-8} = BF;
480 let Inst{9-10} = 0;
481 let Inst{11-13} = BFA;
482 let Inst{14-15} = 0;
483 let Inst{16-20} = 0;
484 let Inst{21-30} = xo;
485 let Inst{31} = 0;
486}
487
488// 1.7.8 XFX-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000489class XFXForm_1<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000491 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 bits<5> RT;
493 bits<10> SPR;
494
495 let Inst{6-10} = RT;
496 let Inst{11} = SPR{4};
497 let Inst{12} = SPR{3};
498 let Inst{13} = SPR{2};
499 let Inst{14} = SPR{1};
500 let Inst{15} = SPR{0};
501 let Inst{16} = SPR{9};
502 let Inst{17} = SPR{8};
503 let Inst{18} = SPR{7};
504 let Inst{19} = SPR{6};
505 let Inst{20} = SPR{5};
506 let Inst{21-30} = xo;
507 let Inst{31} = 0;
508}
509
510class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
Evan Chengb783fa32007-07-19 01:14:50 +0000511 dag OOL, dag IOL, string asmstr, InstrItinClass itin>
512 : XFXForm_1<opcode, xo, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513 let SPR = spr;
514}
515
Evan Chengb783fa32007-07-19 01:14:50 +0000516class XFXForm_3<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000518 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 bits<5> RT;
520
521 let Inst{6-10} = RT;
522 let Inst{11-20} = 0;
523 let Inst{21-30} = xo;
524 let Inst{31} = 0;
525}
526
Evan Chengb783fa32007-07-19 01:14:50 +0000527class XFXForm_5<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000529 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 bits<8> FXM;
531 bits<5> ST;
532
533 let Inst{6-10} = ST;
534 let Inst{11} = 0;
535 let Inst{12-19} = FXM;
536 let Inst{20} = 0;
537 let Inst{21-30} = xo;
538 let Inst{31} = 0;
539}
540
Evan Chengb783fa32007-07-19 01:14:50 +0000541class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000543 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 bits<5> ST;
545 bits<8> FXM;
546
547 let Inst{6-10} = ST;
548 let Inst{11} = 1;
549 let Inst{12-19} = FXM;
550 let Inst{20} = 0;
551 let Inst{21-30} = xo;
552 let Inst{31} = 0;
553}
554
Evan Chengb783fa32007-07-19 01:14:50 +0000555class XFXForm_7<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 InstrItinClass itin>
Evan Chengb783fa32007-07-19 01:14:50 +0000557 : XFXForm_1<opcode, xo, OOL, IOL, asmstr, itin>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558
559class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
Evan Chengb783fa32007-07-19 01:14:50 +0000560 dag OOL, dag IOL, string asmstr, InstrItinClass itin>
561 : XFXForm_7<opcode, xo, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562 let SPR = spr;
563}
564
Dale Johannesen3d8578b2007-10-10 01:01:31 +0000565// XFL-Form - MTFSF
566// This is probably 1.7.9, but I don't have the reference that uses this
567// numbering scheme...
568class XFLForm<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
569 string cstr, InstrItinClass itin, list<dag>pattern>
570 : I<opcode, OOL, IOL, asmstr, itin> {
571 bits<8> FM;
572 bits<5> RT;
573
574 bit RC = 0; // set by isDOT
575 let Pattern = pattern;
576 let Constraints = cstr;
577
578 let Inst{6} = 0;
579 let Inst{7-14} = FM;
580 let Inst{15} = 0;
581 let Inst{16-20} = RT;
582 let Inst{21-30} = xo;
583 let Inst{31} = RC;
584}
585
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586// 1.7.10 XS-Form - SRADI.
Evan Chengb783fa32007-07-19 01:14:50 +0000587class XSForm_1<bits<6> opcode, bits<9> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000589 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590 bits<5> A;
591 bits<5> RS;
592 bits<6> SH;
593
594 bit RC = 0; // set by isDOT
595 let Pattern = pattern;
596
597 let Inst{6-10} = RS;
598 let Inst{11-15} = A;
599 let Inst{16-20} = SH{4,3,2,1,0};
600 let Inst{21-29} = xo;
601 let Inst{30} = SH{5};
602 let Inst{31} = RC;
603}
604
605// 1.7.11 XO-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000606class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000608 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 bits<5> RT;
610 bits<5> RA;
611 bits<5> RB;
612
613 let Pattern = pattern;
614
615 bit RC = 0; // set by isDOT
616
617 let Inst{6-10} = RT;
618 let Inst{11-15} = RA;
619 let Inst{16-20} = RB;
620 let Inst{21} = oe;
621 let Inst{22-30} = xo;
622 let Inst{31} = RC;
623}
624
625class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
Evan Chengb783fa32007-07-19 01:14:50 +0000626 dag OOL, dag IOL, string asmstr, InstrItinClass itin, list<dag> pattern>
627 : XOForm_1<opcode, xo, oe, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628 let RB = 0;
629}
630
631// 1.7.12 A-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000632class AForm_1<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000634 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635 bits<5> FRT;
636 bits<5> FRA;
637 bits<5> FRC;
638 bits<5> FRB;
639
640 let Pattern = pattern;
641
642 bit RC = 0; // set by isDOT
643
644 let Inst{6-10} = FRT;
645 let Inst{11-15} = FRA;
646 let Inst{16-20} = FRB;
647 let Inst{21-25} = FRC;
648 let Inst{26-30} = xo;
649 let Inst{31} = RC;
650}
651
Evan Chengb783fa32007-07-19 01:14:50 +0000652class AForm_2<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000654 : AForm_1<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655 let FRC = 0;
656}
657
Evan Chengb783fa32007-07-19 01:14:50 +0000658class AForm_3<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000660 : AForm_1<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 let FRB = 0;
662}
663
664// 1.7.13 M-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000665class MForm_1<bits<6> opcode, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000667 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000668 bits<5> RA;
669 bits<5> RS;
670 bits<5> RB;
671 bits<5> MB;
672 bits<5> ME;
673
674 let Pattern = pattern;
675
676 bit RC = 0; // set by isDOT
677
678 let Inst{6-10} = RS;
679 let Inst{11-15} = RA;
680 let Inst{16-20} = RB;
681 let Inst{21-25} = MB;
682 let Inst{26-30} = ME;
683 let Inst{31} = RC;
684}
685
Evan Chengb783fa32007-07-19 01:14:50 +0000686class MForm_2<bits<6> opcode, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000688 : MForm_1<opcode, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689}
690
691// 1.7.14 MD-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000692class MDForm_1<bits<6> opcode, bits<3> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000694 : I<opcode, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 bits<5> RA;
696 bits<5> RS;
697 bits<6> SH;
698 bits<6> MBE;
699
700 let Pattern = pattern;
701
702 bit RC = 0; // set by isDOT
703
704 let Inst{6-10} = RS;
705 let Inst{11-15} = RA;
706 let Inst{16-20} = SH{4,3,2,1,0};
707 let Inst{21-26} = MBE{4,3,2,1,0,5};
708 let Inst{27-29} = xo;
709 let Inst{30} = SH{5};
710 let Inst{31} = RC;
711}
712
713
714
715// E-1 VA-Form
716
717// VAForm_1 - DACB ordering.
Evan Chengb783fa32007-07-19 01:14:50 +0000718class VAForm_1<bits<6> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000720 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 bits<5> VD;
722 bits<5> VA;
723 bits<5> VC;
724 bits<5> VB;
725
726 let Pattern = pattern;
727
728 let Inst{6-10} = VD;
729 let Inst{11-15} = VA;
730 let Inst{16-20} = VB;
731 let Inst{21-25} = VC;
732 let Inst{26-31} = xo;
733}
734
735// VAForm_1a - DABC ordering.
Evan Chengb783fa32007-07-19 01:14:50 +0000736class VAForm_1a<bits<6> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000738 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 bits<5> VD;
740 bits<5> VA;
741 bits<5> VB;
742 bits<5> VC;
743
744 let Pattern = pattern;
745
746 let Inst{6-10} = VD;
747 let Inst{11-15} = VA;
748 let Inst{16-20} = VB;
749 let Inst{21-25} = VC;
750 let Inst{26-31} = xo;
751}
752
Evan Chengb783fa32007-07-19 01:14:50 +0000753class VAForm_2<bits<6> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000755 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 bits<5> VD;
757 bits<5> VA;
758 bits<5> VB;
759 bits<4> SH;
760
761 let Pattern = pattern;
762
763 let Inst{6-10} = VD;
764 let Inst{11-15} = VA;
765 let Inst{16-20} = VB;
766 let Inst{21} = 0;
767 let Inst{22-25} = SH;
768 let Inst{26-31} = xo;
769}
770
771// E-2 VX-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000772class VXForm_1<bits<11> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000774 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 bits<5> VD;
776 bits<5> VA;
777 bits<5> VB;
778
779 let Pattern = pattern;
780
781 let Inst{6-10} = VD;
782 let Inst{11-15} = VA;
783 let Inst{16-20} = VB;
784 let Inst{21-31} = xo;
785}
786
Evan Chengb783fa32007-07-19 01:14:50 +0000787class VXForm_setzero<bits<11> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000789 : VXForm_1<xo, OOL, IOL, asmstr, itin, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790 let VA = VD;
791 let VB = VD;
792}
793
794
Evan Chengb783fa32007-07-19 01:14:50 +0000795class VXForm_2<bits<11> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000797 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 bits<5> VD;
799 bits<5> VB;
800
801 let Pattern = pattern;
802
803 let Inst{6-10} = VD;
804 let Inst{11-15} = 0;
805 let Inst{16-20} = VB;
806 let Inst{21-31} = xo;
807}
808
Evan Chengb783fa32007-07-19 01:14:50 +0000809class VXForm_3<bits<11> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000811 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 bits<5> VD;
813 bits<5> IMM;
814
815 let Pattern = pattern;
816
817 let Inst{6-10} = VD;
818 let Inst{11-15} = IMM;
819 let Inst{16-20} = 0;
820 let Inst{21-31} = xo;
821}
822
823/// VXForm_4 - VX instructions with "VD,0,0" register fields, like mfvscr.
Evan Chengb783fa32007-07-19 01:14:50 +0000824class VXForm_4<bits<11> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000826 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 bits<5> VD;
828
829 let Pattern = pattern;
830
831 let Inst{6-10} = VD;
832 let Inst{11-15} = 0;
833 let Inst{16-20} = 0;
834 let Inst{21-31} = xo;
835}
836
837/// VXForm_5 - VX instructions with "0,0,VB" register fields, like mtvscr.
Evan Chengb783fa32007-07-19 01:14:50 +0000838class VXForm_5<bits<11> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000840 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 bits<5> VB;
842
843 let Pattern = pattern;
844
845 let Inst{6-10} = 0;
846 let Inst{11-15} = 0;
847 let Inst{16-20} = VB;
848 let Inst{21-31} = xo;
849}
850
851// E-4 VXR-Form
Evan Chengb783fa32007-07-19 01:14:50 +0000852class VXRForm_1<bits<10> xo, dag OOL, dag IOL, string asmstr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 InstrItinClass itin, list<dag> pattern>
Evan Chengb783fa32007-07-19 01:14:50 +0000854 : I<4, OOL, IOL, asmstr, itin> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 bits<5> VD;
856 bits<5> VA;
857 bits<5> VB;
858 bit RC = 0;
859
860 let Pattern = pattern;
861
862 let Inst{6-10} = VD;
863 let Inst{11-15} = VA;
864 let Inst{16-20} = VB;
865 let Inst{21} = RC;
866 let Inst{22-31} = xo;
867}
868
869//===----------------------------------------------------------------------===//
Evan Chengb783fa32007-07-19 01:14:50 +0000870class Pseudo<dag OOL, dag IOL, string asmstr, list<dag> pattern>
871 : I<0, OOL, IOL, asmstr, NoItinerary> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 let PPC64 = 0;
873 let Pattern = pattern;
874 let Inst{31-0} = 0;
875}