blob: 7e54786f8c89a8ba55c2b147414d1e1bea8763ae [file] [log] [blame]
Misha Brukmancd4f51b2004-08-02 16:54:54 +00001//===- PowerPCInstrFormats.td - PowerPC Instruction Formats --*- tablegen -*-=//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//
11//===----------------------------------------------------------------------===//
12
13class Format<bits<5> val> {
14 bits<5> Value = val;
15}
16
17def Pseudo: Format<0>;
18def Gpr : Format<1>;
19def Gpr0 : Format<2>;
20def Simm16 : Format<3>;
21def Zimm16 : Format<4>;
22def PCRelimm24 : Format<5>;
23def Imm24 : Format<6>;
24def Imm5 : Format<7>;
25def PCRelimm14 : Format<8>;
26def Imm14 : Format<9>;
27def Imm2 : Format<10>;
28def Crf : Format<11>;
29def Imm3 : Format<12>;
30def Imm1 : Format<13>;
31def Fpr : Format<14>;
32def Imm4 : Format<15>;
33def Imm8 : Format<16>;
34def Disimm16 : Format<17>;
35def Disimm14 : Format<18>;
36def Spr : Format<19>;
37def Sgr : Format<20>;
38def Imm15 : Format<21>;
39def Vpr : Format<22>;
40
Misha Brukman6b21bde2004-08-02 21:56:35 +000041//===----------------------------------------------------------------------===//
42//
43// PowerPC instruction formats
Misha Brukmancd4f51b2004-08-02 16:54:54 +000044
Misha Brukman6b21bde2004-08-02 21:56:35 +000045class PPC32I<string name, bits<6> opcode, bit ppc64, bit vmx> : Instruction {
46 field bits<32> Inst;
Misha Brukmancd4f51b2004-08-02 16:54:54 +000047
Misha Brukman6b21bde2004-08-02 21:56:35 +000048 bits<3> ArgCount;
49 bits<5> Arg0Type;
50 bits<5> Arg1Type;
51 bits<5> Arg2Type;
52 bits<5> Arg3Type;
53 bits<5> Arg4Type;
54 bit PPC64 = ppc64;
55 bit VMX = vmx;
Misha Brukmancd4f51b2004-08-02 16:54:54 +000056
Misha Brukman6b21bde2004-08-02 21:56:35 +000057 let Name = name;
Misha Brukman5295e1d2004-08-09 17:24:04 +000058 let Namespace = "PPC32";
59 let Inst{0-5} = opcode;
Misha Brukmancd4f51b2004-08-02 16:54:54 +000060}
61
Misha Brukman5295e1d2004-08-09 17:24:04 +000062// 1.7.1 I-Form
63class IForm<string name, bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx>
64 : PPC32I<name, opcode, ppc64, vmx> {
65 field bits<24> LI;
Misha Brukman6b21bde2004-08-02 21:56:35 +000066
Misha Brukman5295e1d2004-08-09 17:24:04 +000067 let ArgCount = 1;
68 let Arg0Type = Imm24.Value;
69 let Arg1Type = 0;
70 let Arg2Type = 0;
Misha Brukman6b21bde2004-08-02 21:56:35 +000071 let Arg3Type = 0;
72 let Arg4Type = 0;
73
Misha Brukman5295e1d2004-08-09 17:24:04 +000074 let Inst{6-29} = LI;
75 let Inst{30} = aa;
76 let Inst{31} = lk;
Misha Brukman6b21bde2004-08-02 21:56:35 +000077}
78
Misha Brukman5295e1d2004-08-09 17:24:04 +000079// 1.7.2 B-Form
80class BForm<string name, bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx>
81 : PPC32I<name, opcode, ppc64, vmx> {
82 field bits<5> BO;
83 field bits<5> BI;
84 field bits<14> BD;
85
86 let ArgCount = 3;
87 let Arg0Type = Imm5.Value;
88 let Arg1Type = Imm5.Value;
89 let Arg2Type = PCRelimm14.Value;
90 let Arg3Type = 0;
91 let Arg4Type = 0;
92
93 let Inst{6-10} = BO;
94 let Inst{11-15} = BI;
95 let Inst{16-29} = BD;
96 let Inst{30} = aa;
97 let Inst{31} = lk;
Misha Brukman6b21bde2004-08-02 21:56:35 +000098}
99
Misha Brukman5295e1d2004-08-09 17:24:04 +0000100class BForm_ext<string name, bits<6> opcode, bit aa, bit lk, bits<5> bo,
101 bits<5> bi, bit ppc64, bit vmx>
102 : BForm<name, opcode, aa, lk, ppc64, vmx> {
103 let ArgCount = 2;
Misha Brukman6b21bde2004-08-02 21:56:35 +0000104 let Arg2Type = Imm5.Value;
Misha Brukman5295e1d2004-08-09 17:24:04 +0000105 let Arg1Type = PCRelimm14.Value;
106 let Arg2Type = 0;
107 let BO = bo;
108 let BI = bi;
Misha Brukman6b21bde2004-08-02 21:56:35 +0000109}
110
Misha Brukman5295e1d2004-08-09 17:24:04 +0000111// 1.7.4 D-Form
Misha Brukman6b21bde2004-08-02 21:56:35 +0000112class DForm_base<string name, bits<6> opcode, bit ppc64, bit vmx>
113 : PPC32I<name, opcode, ppc64, vmx> {
114 field bits<5> A;
115 field bits<5> B;
116 field bits<16> C;
117
118 let ArgCount = 3;
119 let Arg0Type = Gpr.Value;
120 let Arg1Type = Gpr.Value;
121 let Arg2Type = Simm16.Value;
122 let Arg3Type = 0;
123 let Arg4Type = 0;
124
125 let Inst{6-10} = A;
126 let Inst{11-15} = B;
127 let Inst{16-31} = C;
128}
129
130class DForm_1<string name, bits<6> opcode, bit ppc64, bit vmx>
131 : DForm_base<name, opcode, ppc64, vmx> {
Misha Brukman5295e1d2004-08-09 17:24:04 +0000132 let Arg1Type = Disimm16.Value;
133 let Arg2Type = Gpr0.Value;
Misha Brukman6b21bde2004-08-02 21:56:35 +0000134}
135
136class DForm_2<string name, bits<6> opcode, bit ppc64, bit vmx>
137 : DForm_base<name, opcode, ppc64, vmx>;
138
139class DForm_2_r0<string name, bits<6> opcode, bit ppc64, bit vmx>
140 : DForm_base<name, opcode, ppc64, vmx> {
141 let Arg1Type = Gpr0.Value;
Misha Brukman5295e1d2004-08-09 17:24:04 +0000142 let B = 0;
Misha Brukman6b21bde2004-08-02 21:56:35 +0000143}
144
145// Currently we make the use/def reg distinction in ISel, not tablegen
146class DForm_3<string name, bits<6> opcode, bit ppc64, bit vmx>
147 : DForm_1<name, opcode, ppc64, vmx>;
148
149class DForm_4<string name, bits<6> opcode, bit ppc64, bit vmx>
150 : DForm_1<name, opcode, ppc64, vmx>;
151
Misha Brukman5295e1d2004-08-09 17:24:04 +0000152class DForm_4_zero<string name, bits<6> opcode, bit ppc64, bit vmx>
153 : DForm_1<name, opcode, ppc64, vmx> {
154 let ArgCount = 0;
155 let Arg0Type = 0;
156 let Arg1Type = 0;
157 let Arg2Type = 0;
158 let A = 0;
159 let B = 0;
160 let C = 0;
161}
162
163class DForm_5<string name, bits<6> opcode, bit ppc64, bit vmx>
164 : PPC32I<name, opcode, ppc64, vmx> {
165 field bits<3> BF;
166 field bits<1> L;
167 field bits<5> RA;
168 field bits<16> I;
169
170 let ArgCount = 4;
171 let Arg0Type = Imm3.Value;
172 let Arg1Type = Imm1.Value;
173 let Arg2Type = Gpr.Value;
174 let Arg3Type = Simm16.Value;
175 let Arg4Type = 0;
176
177 let Inst{6-8} = BF;
178 let Inst{9} = 0;
179 let Inst{10} = L;
180 let Inst{11-15} = RA;
181 let Inst{16-31} = I;
182}
183
184class DForm_5_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
185 : DForm_5<name, opcode, ppc64, vmx> {
186 let L = 0;
187}
188
189class DForm_6<string name, bits<6> opcode, bit ppc64, bit vmx>
190 : DForm_5<name, opcode, ppc64, vmx> {
191 let Arg3Type = Zimm16.Value;
192}
193
194class DForm_6_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
195 : DForm_6<name, opcode, ppc64, vmx> {
196 let L = 0;
197}
198
Misha Brukman6b21bde2004-08-02 21:56:35 +0000199class DForm_7<string name, bits<6> opcode, bit ppc64, bit vmx>
200 : DForm_base<name, opcode, ppc64, vmx> {
201 let Arg1Type = Imm5.Value;
202}
203
Misha Brukman5295e1d2004-08-09 17:24:04 +0000204class DForm_8<string name, bits<6> opcode, bit ppc64, bit vmx>
205 : DForm_1<name, opcode, ppc64, vmx> {
206 let Arg0Type = Fpr.Value;
207}
208
209class DForm_9<string name, bits<6> opcode, bit ppc64, bit vmx>
210 : DForm_1<name, opcode, ppc64, vmx> {
211 let Arg0Type = Fpr.Value;
212}
213
214// 1.7.6 X-Form
215class XForm_base_r3xo<string name, bits<6> opcode, bits<10> xo, bit rc,
216 bit ppc64, bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
217 let ArgCount = 3;
218 field bits<5> ST;
219 field bits<5> A;
220 field bits<5> B;
221
222 let ArgCount = 3;
223 let Arg0Type = Gpr.Value;
224 let Arg1Type = Gpr.Value;
225 let Arg2Type = Gpr.Value;
226 let Arg3Type = 0;
227 let Arg4Type = 0;
228
229 let Inst{6-10} = ST;
230 let Inst{11-15} = A;
231 let Inst{16-20} = B;
232 let Inst{21-30} = xo;
233 let Inst{31} = rc;
234}
235
236class XForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64,
237 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
238
239class XForm_5<string name, bits<6> opcode, bits<10> xo, bit ppc64,
240 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
241 let ArgCount = 1;
242 let Arg1Type = 0;
243 let Arg2Type = 0;
244 let A = 0;
245 let B = 0;
246}
247
248class XForm_6<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
249 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx>;
250
251class XForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
252 : XForm_base_r3xo<name, opcode, xo, 1, ppc64, vmx>;
253
254class XForm_8<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
255 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
256
257class XForm_10<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
258 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
259 let Arg2Type = Imm5.Value;
260}
261
262class XForm_11<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
263 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
264 let ArgCount = 2;
265 let Arg2Type = 0;
266 let B = 0;
267}
268
269class XForm_16<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
270 : PPC32I<name, opcode, ppc64, vmx> {
271 field bits<3> BF;
272 field bits<1> L;
273 field bits<5> RA;
274 field bits<5> RB;
275
276 let ArgCount = 4;
277 let Arg0Type = Imm3.Value;
278 let Arg1Type = Imm1.Value;
279 let Arg2Type = Gpr.Value;
280 let Arg3Type = Gpr.Value;
281 let Arg4Type = 0;
282
283 let Inst{6-8} = BF;
284 let Inst{9} = 0;
285 let Inst{10} = L;
286 let Inst{11-15} = RA;
287 let Inst{16-20} = RB;
288 let Inst{21-30} = xo;
289 let Inst{31} = 0;
290}
291
292class XForm_16_ext<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
293 : XForm_16<name, opcode, xo, ppc64, vmx> {
294 let L = 0;
295}
296
297class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
298 : PPC32I<name, opcode, ppc64, vmx> {
299 field bits<3> BF;
300 field bits<5> FRA;
301 field bits<5> FRB;
302
303 let ArgCount = 3;
304 let Arg0Type = Imm3.Value;
305 let Arg1Type = Fpr.Value;
306 let Arg2Type = Fpr.Value;
307 let Arg3Type = 0;
308 let Arg4Type = 0;
309
310 let Inst{6-8} = BF;
311 let Inst{9-10} = 0;
312 let Inst{11-15} = FRA;
313 let Inst{16-20} = FRB;
314 let Inst{21-30} = xo;
315 let Inst{31} = 0;
316}
317
318class XForm_25<string name, bits<6> opcode, bits<10> xo, bit ppc64,
319 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
320 let Arg0Type = Fpr.Value;
321 let Arg1Type = Gpr0.Value;
322}
323
324class XForm_26<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
325 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
326 let ArgCount = 2;
327 let Arg0Type = Fpr.Value;
328 let Arg1Type = Fpr.Value;
329 let Arg2Type = 0;
330 let A = 0;
331}
332
333class XForm_28<string name, bits<6> opcode, bits<10> xo, bit ppc64,
334 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
335 let Arg0Type = Fpr.Value;
336 let Arg1Type = Gpr0.Value;
337}
338
339// 1.7.7 XL-Form
340class XLForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
341 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
342 let Arg0Type = Imm5.Value;
343 let Arg1Type = Imm5.Value;
344 let Arg2Type = Imm5.Value;
345}
346
347class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
348 bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
349 field bits<5> BO;
350 field bits<5> BI;
351 field bits<2> BH;
352
353 let ArgCount = 3;
354 let Arg0Type = Imm5.Value;
355 let Arg1Type = Imm5.Value;
356 let Arg2Type = Imm2.Value;
357 let Arg3Type = 0;
358 let Arg4Type = 0;
359
360 let Inst{6-10} = BO;
361 let Inst{11-15} = BI;
362 let Inst{16-18} = 0;
363 let Inst{19-20} = BH;
364 let Inst{21-30} = xo;
365 let Inst{31} = lk;
366}
367
368class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
369 bits<5> bi, bit lk, bit ppc64, bit vmx>
370 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
371 let ArgCount = 0;
372 let Arg0Type = 0;
373 let Arg1Type = 0;
374 let Arg2Type = 0;
375 let BO = bo;
376 let BI = bi;
377 let BH = 0;
378}
379
380// 1.7.8 XFX-Form
381class XFXForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
382 : PPC32I<name, opcode, ppc64, vmx> {
383 field bits<5> ST;
384 field bits<10> SPR;
385
386 let ArgCount = 2;
387 let Arg0Type = Imm5.Value;
388 let Arg1Type = Gpr.Value;
389 let Arg2Type = 0;
390 let Arg3Type = 0;
391 let Arg4Type = 0;
392
393 let Inst{6-10} = ST;
394 let Inst{11-20} = SPR;
395 let Inst{21-30} = xo;
396 let Inst{31} = 0;
397}
398
399class XFXForm_1_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
400 bit ppc64, bit vmx> : XFXForm_1<name,opcode,xo,ppc64,vmx> {
401 let ArgCount = 1;
402 let Arg0Type = Gpr.Value;
403 let Arg1Type = 0;
404 let SPR = spr;
405}
406
407class XFXForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
408 : XFXForm_1<name, opcode, xo, ppc64, vmx>;
409
410class XFXForm_7_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
411 bit ppc64, bit vmx> : XFXForm_7<name,opcode,xo,ppc64,vmx> {
412 let ArgCount = 1;
413 let Arg0Type = Gpr.Value;
414 let Arg1Type = 0;
415 let SPR = spr;
416}
417
418// 1.7.11 XO-Form
419class XOForm_1<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
420 bit ppc64, bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
421 field bits<5> RT;
422 field bits<5> RA;
423 field bits<5> RB;
424
425 let ArgCount = 3;
426 let Arg0Type = Gpr.Value;
427 let Arg1Type = Gpr.Value;
428 let Arg2Type = Gpr.Value;
429 let Arg3Type = 0;
430 let Arg4Type = 0;
431
432 let Inst{6-10} = RT;
433 let Inst{11-15} = RA;
434 let Inst{16-20} = RB;
435 let Inst{21} = oe;
436 let Inst{22-30} = xo;
437 let Inst{31} = rc;
438}
439
440// This is a reversal of the two operands, used notably by extended ops SUB*:
441// sub x, y, z == subf x, z, y
442// subc x, y, z == subfc x, z, y
443class XOForm_1_rev<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
444 bit ppc64, bit vmx>
445 : XOForm_1<name, opcode, xo, oe, rc, ppc64, vmx> {
446 let Inst{11-15} = RB;
447 let Inst{16-20} = RA;
448}
449
450class XOForm_2<string name, bits<6> opcode, bits<9> xo, bit rc, bit ppc64,
451 bit vmx> : XOForm_1<name, opcode, xo, 0, rc, ppc64, vmx>;
452
453class XOForm_3<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
454 bit ppc64, bit vmx> : XOForm_1<name,opcode,xo,oe,rc,ppc64,vmx> {
455 let RB = 0;
456}
457
458// 1.7.12 A-Form
459class AForm_1<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
460 bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
461 let ArgCount = 4;
462 field bits<5> FRT;
463 field bits<5> FRA;
464 field bits<5> FRB;
465 field bits<5> FRC;
466
467 let Arg0Type = Fpr.Value;
468 let Arg1Type = Fpr.Value;
469 let Arg2Type = Fpr.Value;
470 let Arg3Type = Fpr.Value;
471 let Arg4Type = 0;
472
473 let Inst{6-10} = FRT;
474 let Inst{11-15} = FRA;
475 let Inst{16-20} = FRB;
476 let Inst{21-25} = FRC;
477 let Inst{26-30} = xo;
478 let Inst{31} = rc;
479}
480
481class AForm_2<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
482 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
483 let ArgCount = 3;
484 let Arg3Type = 0;
485 let FRC = 0;
486}
487
488class AForm_3<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
489 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
490 let ArgCount = 3;
491 let Arg3Type = 0;
492 let FRB = 0;
493}
494
495class AForm_4<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
496 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
497 let ArgCount = 2;
498 let Arg2Type = 0;
499 let Arg3Type = 0;
500 let FRA = 0;
501 let FRC = 0;
502}
503
504// 1.7.13 M-Form
505class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
506 : PPC32I<name, opcode, ppc64, vmx> {
507 let ArgCount = 5;
508 field bits<5> RS;
509 field bits<5> RA;
510 field bits<5> RB;
511 field bits<5> MB;
512 field bits<5> ME;
513
514 let Arg0Type = Gpr.Value;
515 let Arg1Type = Gpr.Value;
516 let Arg2Type = Gpr.Value;
517 let Arg3Type = Imm5.Value;
518 let Arg4Type = Imm5.Value;
519
520 let Inst{6-10} = RS;
521 let Inst{11-15} = RA;
522 let Inst{16-20} = RB;
523 let Inst{21-25} = MB;
524 let Inst{26-30} = ME;
525 let Inst{31} = rc;
526}
527
528class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
529 : MForm_1<name, opcode, rc, ppc64, vmx> {
530 let Arg2Type = Imm5.Value;
531}
532
Misha Brukman6b21bde2004-08-02 21:56:35 +0000533//===----------------------------------------------------------------------===//
534
Misha Brukman5295e1d2004-08-09 17:24:04 +0000535class Pseudo<string name> : PPC32I<name, 0, 0, 0> {
Misha Brukmancd4f51b2004-08-02 16:54:54 +0000536 let Name = name;
537 let ArgCount = 0;
538 let PPC64 = 0;
539 let VMX = 0;
540
Misha Brukman5295e1d2004-08-09 17:24:04 +0000541 let Arg0Type = Pseudo.Value;
542 let Arg1Type = Pseudo.Value;
543 let Arg2Type = Pseudo.Value;
544 let Arg3Type = Pseudo.Value;
Misha Brukmancd4f51b2004-08-02 16:54:54 +0000545 let Arg4Type = 0;
Misha Brukmancd4f51b2004-08-02 16:54:54 +0000546
547 let Inst {31-0} = 0;
548}