1 //===-- SIInstrFormats.td - SI Instruction Encodings ----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // SI Instruction format definitions.
12 //===----------------------------------------------------------------------===//
14 class InstSI <dag outs, dag ins, string asm, list<dag> pattern> :
15 AMDGPUInst<outs, ins, asm, pattern>, PredicateControl {
17 field bits<1> VM_CNT = 0;
18 field bits<1> EXP_CNT = 0;
19 field bits<1> LGKM_CNT = 0;
21 field bits<1> SALU = 0;
22 field bits<1> VALU = 0;
24 field bits<1> SOP1 = 0;
25 field bits<1> SOP2 = 0;
26 field bits<1> SOPC = 0;
27 field bits<1> SOPK = 0;
28 field bits<1> SOPP = 0;
30 field bits<1> VOP1 = 0;
31 field bits<1> VOP2 = 0;
32 field bits<1> VOP3 = 0;
33 field bits<1> VOPC = 0;
35 field bits<1> MUBUF = 0;
36 field bits<1> MTBUF = 0;
37 field bits<1> SMRD = 0;
39 field bits<1> MIMG = 0;
40 field bits<1> FLAT = 0;
41 field bits<1> WQM = 0;
42 field bits<1> VGPRSpill = 0;
44 // This bit tells the assembler to use the 32-bit encoding in case it
45 // is unable to infer the encoding from the operands.
46 field bits<1> VOPAsmPrefer32Bit = 0;
48 // These need to be kept in sync with the enum in SIInstrFlags.
49 let TSFlags{0} = VM_CNT;
50 let TSFlags{1} = EXP_CNT;
51 let TSFlags{2} = LGKM_CNT;
53 let TSFlags{3} = SALU;
54 let TSFlags{4} = VALU;
56 let TSFlags{5} = SOP1;
57 let TSFlags{6} = SOP2;
58 let TSFlags{7} = SOPC;
59 let TSFlags{8} = SOPK;
60 let TSFlags{9} = SOPP;
62 let TSFlags{10} = VOP1;
63 let TSFlags{11} = VOP2;
64 let TSFlags{12} = VOP3;
65 let TSFlags{13} = VOPC;
67 let TSFlags{14} = MUBUF;
68 let TSFlags{15} = MTBUF;
69 let TSFlags{16} = SMRD;
71 let TSFlags{18} = MIMG;
72 let TSFlags{19} = FLAT;
73 let TSFlags{20} = WQM;
74 let TSFlags{21} = VGPRSpill;
75 let TSFlags{22} = VOPAsmPrefer32Bit;
77 let SchedRW = [Write32Bit];
90 class VOPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVOPDst">;
92 let Uses = [EXEC] in {
94 class VOPAnyCommon <dag outs, dag ins, string asm, list<dag> pattern> :
95 InstSI <outs, ins, asm, pattern> {
99 let hasSideEffects = 0;
100 let UseNamedOperandTable = 1;
104 class VOPCCommon <dag ins, string asm, list<dag> pattern> :
105 VOPAnyCommon <(outs), ins, asm, pattern> {
112 class VOP1Common <dag outs, dag ins, string asm, list<dag> pattern> :
113 VOPAnyCommon <outs, ins, asm, pattern> {
119 class VOP2Common <dag outs, dag ins, string asm, list<dag> pattern> :
120 VOPAnyCommon <outs, ins, asm, pattern> {
126 class VOP3Common <dag outs, dag ins, string asm, list<dag> pattern> :
127 VOPAnyCommon <outs, ins, asm, pattern> {
129 // Using complex patterns gives VOP3 patterns a very high complexity rating,
130 // but standalone patterns are almost always prefered, so we need to adjust the
131 // priority lower. The goal is to use a high number to reduce complexity to
132 // zero (or less than zero).
133 let AddedComplexity = -1000;
138 let AsmMatchConverter = "cvtVOP3";
139 let isCodeGenOnly = 0;
143 // Because SGPRs may be allowed if there are multiple operands, we
144 // need a post-isel hook to insert copies in order to avoid
145 // violating constant bus requirements.
146 let hasPostISelHook = 1;
149 } // End Uses = [EXEC]
151 //===----------------------------------------------------------------------===//
153 //===----------------------------------------------------------------------===//
155 class SOP1e <bits<8> op> : Enc32 {
159 let Inst{7-0} = ssrc0;
161 let Inst{22-16} = sdst;
162 let Inst{31-23} = 0x17d; //encoding;
165 class SOP2e <bits<7> op> : Enc32 {
170 let Inst{7-0} = ssrc0;
171 let Inst{15-8} = ssrc1;
172 let Inst{22-16} = sdst;
173 let Inst{29-23} = op;
174 let Inst{31-30} = 0x2; // encoding
177 class SOPCe <bits<7> op> : Enc32 {
181 let Inst{7-0} = ssrc0;
182 let Inst{15-8} = ssrc1;
183 let Inst{22-16} = op;
184 let Inst{31-23} = 0x17e;
187 class SOPKe <bits<5> op> : Enc32 {
191 let Inst{15-0} = simm16;
192 let Inst{22-16} = sdst;
193 let Inst{27-23} = op;
194 let Inst{31-28} = 0xb; //encoding
197 class SOPK64e <bits<5> op> : Enc64 {
202 let Inst{15-0} = simm16;
203 let Inst{22-16} = sdst;
204 let Inst{27-23} = op;
205 let Inst{31-28} = 0xb;
207 let Inst{63-32} = imm;
210 class SOPPe <bits<7> op> : Enc32 {
213 let Inst{15-0} = simm16;
214 let Inst{22-16} = op;
215 let Inst{31-23} = 0x17f; // encoding
218 class SMRDe <bits<5> op, bits<1> imm> : Enc32 {
223 let Inst{7-0} = offset;
225 let Inst{14-9} = sbase{6-1};
226 let Inst{21-15} = sdst;
227 let Inst{26-22} = op;
228 let Inst{31-27} = 0x18; //encoding
231 class SMRD_IMMe_ci <bits<5> op> : Enc64 {
236 let Inst{7-0} = 0xff;
238 let Inst{14-9} = sbase{6-1};
239 let Inst{21-15} = sdst;
240 let Inst{26-22} = op;
241 let Inst{31-27} = 0x18; //encoding
242 let Inst{63-32} = offset;
245 let SchedRW = [WriteSALU] in {
246 class SOP1 <dag outs, dag ins, string asm, list<dag> pattern> :
247 InstSI<outs, ins, asm, pattern> {
250 let hasSideEffects = 0;
251 let isCodeGenOnly = 0;
256 class SOP2 <dag outs, dag ins, string asm, list<dag> pattern> :
257 InstSI <outs, ins, asm, pattern> {
261 let hasSideEffects = 0;
262 let isCodeGenOnly = 0;
266 let UseNamedOperandTable = 1;
269 class SOPC <bits<7> op, dag outs, dag ins, string asm, list<dag> pattern> :
270 InstSI<outs, ins, asm, pattern>, SOPCe <op> {
274 let hasSideEffects = 0;
277 let isCodeGenOnly = 0;
280 let UseNamedOperandTable = 1;
283 class SOPK <dag outs, dag ins, string asm, list<dag> pattern> :
284 InstSI <outs, ins , asm, pattern> {
288 let hasSideEffects = 0;
292 let UseNamedOperandTable = 1;
295 class SOPP <bits<7> op, dag ins, string asm, list<dag> pattern = []> :
296 InstSI <(outs), ins, asm, pattern >, SOPPe <op> {
300 let hasSideEffects = 0;
304 let UseNamedOperandTable = 1;
307 } // let SchedRW = [WriteSALU]
309 class SMRD <dag outs, dag ins, string asm, list<dag> pattern> :
310 InstSI<outs, ins, asm, pattern> {
316 let hasSideEffects = 0;
317 let UseNamedOperandTable = 1;
318 let SchedRW = [WriteSMEM];
321 //===----------------------------------------------------------------------===//
322 // Vector ALU operations
323 //===----------------------------------------------------------------------===//
325 class VOP1e <bits<8> op> : Enc32 {
329 let Inst{8-0} = src0;
331 let Inst{24-17} = vdst;
332 let Inst{31-25} = 0x3f; //encoding
335 class VOP2e <bits<6> op> : Enc32 {
340 let Inst{8-0} = src0;
341 let Inst{16-9} = src1;
342 let Inst{24-17} = vdst;
343 let Inst{30-25} = op;
344 let Inst{31} = 0x0; //encoding
347 class VOP2_MADKe <bits<6> op> : Enc64 {
354 let Inst{8-0} = src0;
355 let Inst{16-9} = vsrc1;
356 let Inst{24-17} = vdst;
357 let Inst{30-25} = op;
358 let Inst{31} = 0x0; // encoding
359 let Inst{63-32} = src2;
362 class VOP3e <bits<9> op> : Enc64 {
364 bits<2> src0_modifiers;
366 bits<2> src1_modifiers;
368 bits<2> src2_modifiers;
373 let Inst{7-0} = vdst;
374 let Inst{8} = src0_modifiers{1};
375 let Inst{9} = src1_modifiers{1};
376 let Inst{10} = src2_modifiers{1};
377 let Inst{11} = clamp;
378 let Inst{25-17} = op;
379 let Inst{31-26} = 0x34; //encoding
380 let Inst{40-32} = src0;
381 let Inst{49-41} = src1;
382 let Inst{58-50} = src2;
383 let Inst{60-59} = omod;
384 let Inst{61} = src0_modifiers{0};
385 let Inst{62} = src1_modifiers{0};
386 let Inst{63} = src2_modifiers{0};
389 class VOP3be <bits<9> op> : Enc64 {
391 bits<2> src0_modifiers;
393 bits<2> src1_modifiers;
395 bits<2> src2_modifiers;
400 let Inst{7-0} = vdst;
401 let Inst{14-8} = sdst;
402 let Inst{25-17} = op;
403 let Inst{31-26} = 0x34; //encoding
404 let Inst{40-32} = src0;
405 let Inst{49-41} = src1;
406 let Inst{58-50} = src2;
407 let Inst{60-59} = omod;
408 let Inst{61} = src0_modifiers{0};
409 let Inst{62} = src1_modifiers{0};
410 let Inst{63} = src2_modifiers{0};
413 class VOPCe <bits<8> op> : Enc32 {
417 let Inst{8-0} = src0;
418 let Inst{16-9} = vsrc1;
419 let Inst{24-17} = op;
420 let Inst{31-25} = 0x3e;
423 class VINTRPe <bits<2> op> : Enc32 {
429 let Inst{7-0} = vsrc;
430 let Inst{9-8} = attrchan;
431 let Inst{15-10} = attr;
432 let Inst{17-16} = op;
433 let Inst{25-18} = vdst;
434 let Inst{31-26} = 0x32; // encoding
437 class DSe <bits<8> op> : Enc64 {
446 let Inst{7-0} = offset0;
447 let Inst{15-8} = offset1;
449 let Inst{25-18} = op;
450 let Inst{31-26} = 0x36; //encoding
451 let Inst{39-32} = addr;
452 let Inst{47-40} = data0;
453 let Inst{55-48} = data1;
454 let Inst{63-56} = vdst;
457 class MUBUFe <bits<7> op> : Enc64 {
471 let Inst{11-0} = offset;
472 let Inst{12} = offen;
473 let Inst{13} = idxen;
475 let Inst{15} = addr64;
477 let Inst{24-18} = op;
478 let Inst{31-26} = 0x38; //encoding
479 let Inst{39-32} = vaddr;
480 let Inst{47-40} = vdata;
481 let Inst{52-48} = srsrc{6-2};
484 let Inst{63-56} = soffset;
487 class MTBUFe <bits<3> op> : Enc64 {
502 let Inst{11-0} = offset;
503 let Inst{12} = offen;
504 let Inst{13} = idxen;
506 let Inst{15} = addr64;
507 let Inst{18-16} = op;
508 let Inst{22-19} = dfmt;
509 let Inst{25-23} = nfmt;
510 let Inst{31-26} = 0x3a; //encoding
511 let Inst{39-32} = vaddr;
512 let Inst{47-40} = vdata;
513 let Inst{52-48} = srsrc{6-2};
516 let Inst{63-56} = soffset;
519 class MIMGe <bits<7> op> : Enc64 {
533 let Inst{11-8} = dmask;
534 let Inst{12} = unorm;
540 let Inst{24-18} = op;
542 let Inst{31-26} = 0x3c;
543 let Inst{39-32} = vaddr;
544 let Inst{47-40} = vdata;
545 let Inst{52-48} = srsrc{6-2};
546 let Inst{57-53} = ssamp{6-2};
549 class FLATe<bits<7> op> : Enc64 {
560 let Inst{24-18} = op;
561 let Inst{31-26} = 0x37; // Encoding.
562 let Inst{39-32} = addr;
563 let Inst{47-40} = data;
564 // 54-48 is reserved.
566 let Inst{63-56} = vdst;
582 let Inst{10} = compr;
585 let Inst{31-26} = 0x3e;
586 let Inst{39-32} = vsrc0;
587 let Inst{47-40} = vsrc1;
588 let Inst{55-48} = vsrc2;
589 let Inst{63-56} = vsrc3;
592 let Uses = [EXEC] in {
594 class VOP1 <bits<8> op, dag outs, dag ins, string asm, list<dag> pattern> :
595 VOP1Common <outs, ins, asm, pattern>,
597 let isCodeGenOnly = 0;
600 class VOP2 <bits<6> op, dag outs, dag ins, string asm, list<dag> pattern> :
601 VOP2Common <outs, ins, asm, pattern>, VOP2e<op> {
602 let isCodeGenOnly = 0;
605 class VOPC <bits<8> op, dag ins, string asm, list<dag> pattern> :
606 VOPCCommon <ins, asm, pattern>, VOPCe <op>;
608 class VINTRPCommon <dag outs, dag ins, string asm, list<dag> pattern> :
609 InstSI <outs, ins, asm, pattern> {
612 let hasSideEffects = 0;
615 } // End Uses = [EXEC]
617 //===----------------------------------------------------------------------===//
618 // Vector I/O operations
619 //===----------------------------------------------------------------------===//
621 class DS <dag outs, dag ins, string asm, list<dag> pattern> :
622 InstSI <outs, ins, asm, pattern> {
626 let UseNamedOperandTable = 1;
627 let Uses = [M0, EXEC];
629 // Most instruction load and store data, so set this as the default.
633 let hasSideEffects = 0;
634 let AsmMatchConverter = "cvtDS";
635 let SchedRW = [WriteLDS];
638 class MUBUF <dag outs, dag ins, string asm, list<dag> pattern> :
639 InstSI<outs, ins, asm, pattern> {
646 let hasSideEffects = 0;
647 let UseNamedOperandTable = 1;
648 let AsmMatchConverter = "cvtMubuf";
649 let SchedRW = [WriteVMEM];
652 class MTBUF <dag outs, dag ins, string asm, list<dag> pattern> :
653 InstSI<outs, ins, asm, pattern> {
660 let hasSideEffects = 0;
661 let UseNamedOperandTable = 1;
662 let SchedRW = [WriteVMEM];
665 class FLAT <bits<7> op, dag outs, dag ins, string asm, list<dag> pattern> :
666 InstSI<outs, ins, asm, pattern>, FLATe <op> {
668 // Internally, FLAT instruction are executed as both an LDS and a
669 // Buffer instruction; so, they increment both VM_CNT and LGKM_CNT
670 // and are not considered done until both have been decremented.
674 let Uses = [EXEC, FLAT_SCR]; // M0
676 let UseNamedOperandTable = 1;
677 let hasSideEffects = 0;
678 let AsmMatchConverter = "cvtFlat";
679 let SchedRW = [WriteVMEM];
682 class MIMG <bits<7> op, dag outs, dag ins, string asm, list<dag> pattern> :
683 InstSI <outs, ins, asm, pattern>, MIMGe <op> {
690 let hasSideEffects = 0; // XXX ????