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 = "",
15 list<dag> pattern = []> :
16 AMDGPUInst<outs, ins, asm, pattern>, PredicateControl {
18 // Low bits - basic encoding information.
22 // SALU instruction formats.
29 // VALU instruction formats.
38 // Memory instruction formats.
47 // Pseudo instruction formats.
48 field bit VGPRSpill = 0;
49 field bit SGPRSpill = 0;
51 // High bits - other information.
53 field bit EXP_CNT = 0;
54 field bit LGKM_CNT = 0;
56 // Whether WQM _must_ be enabled for this instruction.
59 // Whether WQM _must_ be disabled for this instruction.
60 field bit DisableWQM = 0;
62 field bit Gather4 = 0;
64 // Most sopk treat the immediate as a signed 16-bit, however some
65 // use it as unsigned.
66 field bit SOPKZext = 0;
68 // This is an s_store_dword* instruction that requires a cache flush
69 // on wave termination. It is necessary to distinguish from mayStore
70 // SMEM instructions like the cache flush ones.
71 field bit ScalarStore = 0;
73 // Whether the operands can be ignored when computing the
75 field bit FixedSize = 0;
77 // This bit tells the assembler to use the 32-bit encoding in case it
78 // is unable to infer the encoding from the operands.
79 field bit VOPAsmPrefer32Bit = 0;
81 // These need to be kept in sync with the enum in SIInstrFlags.
82 let TSFlags{0} = SALU;
83 let TSFlags{1} = VALU;
85 let TSFlags{2} = SOP1;
86 let TSFlags{3} = SOP2;
87 let TSFlags{4} = SOPC;
88 let TSFlags{5} = SOPK;
89 let TSFlags{6} = SOPP;
91 let TSFlags{7} = VOP1;
92 let TSFlags{8} = VOP2;
93 let TSFlags{9} = VOPC;
94 let TSFlags{10} = VOP3;
96 let TSFlags{13} = VINTRP;
97 let TSFlags{14} = SDWA;
98 let TSFlags{15} = DPP;
100 let TSFlags{16} = MUBUF;
101 let TSFlags{17} = MTBUF;
102 let TSFlags{18} = SMRD;
103 let TSFlags{19} = MIMG;
104 let TSFlags{20} = EXP;
105 let TSFlags{21} = FLAT;
106 let TSFlags{22} = DS;
108 let TSFlags{23} = VGPRSpill;
109 let TSFlags{24} = SGPRSpill;
111 let TSFlags{32} = VM_CNT;
112 let TSFlags{33} = EXP_CNT;
113 let TSFlags{34} = LGKM_CNT;
115 let TSFlags{35} = WQM;
116 let TSFlags{36} = DisableWQM;
117 let TSFlags{37} = Gather4;
119 let TSFlags{38} = SOPKZext;
120 let TSFlags{39} = ScalarStore;
121 let TSFlags{40} = FixedSize;
122 let TSFlags{41} = VOPAsmPrefer32Bit;
124 let SchedRW = [Write32Bit];
126 field bits<1> DisableSIDecoder = 0;
127 field bits<1> DisableVIDecoder = 0;
128 field bits<1> DisableDecoder = 0;
130 let isAsmParserOnly = !if(!eq(DisableDecoder{0}, {0}), 0, 1);
131 let AsmVariantName = AMDGPUAsmVariants.Default;
134 class PseudoInstSI<dag outs, dag ins, list<dag> pattern = []>
135 : InstSI<outs, ins, "", pattern> {
137 let isCodeGenOnly = 1;
140 class SPseudoInstSI<dag outs, dag ins, list<dag> pattern = []>
141 : PseudoInstSI<outs, ins, pattern> {
145 class VPseudoInstSI<dag outs, dag ins, list<dag> pattern = []>
146 : PseudoInstSI<outs, ins, pattern> {
151 class CFPseudoInstSI<dag outs, dag ins, list<dag> pattern = [],
152 bit UseExec = 0, bit DefExec = 0> :
153 SPseudoInstSI<outs, ins, pattern> {
155 let Uses = !if(UseExec, [EXEC], []);
156 let Defs = !if(DefExec, [EXEC, SCC], [SCC]);
159 let hasSideEffects = 0;
172 class VOPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVOPDst">;
174 class VINTRPe <bits<2> op> : Enc32 {
180 let Inst{7-0} = vsrc;
181 let Inst{9-8} = attrchan;
182 let Inst{15-10} = attr;
183 let Inst{17-16} = op;
184 let Inst{25-18} = vdst;
185 let Inst{31-26} = 0x32; // encoding
188 class MIMGe <bits<7> op> : Enc64 {
202 let Inst{11-8} = dmask;
203 let Inst{12} = unorm;
209 let Inst{24-18} = op;
211 let Inst{31-26} = 0x3c;
212 let Inst{39-32} = vaddr;
213 let Inst{47-40} = vdata;
214 let Inst{52-48} = srsrc{6-2};
215 let Inst{57-53} = ssamp{6-2};
231 let Inst{10} = compr;
234 let Inst{31-26} = 0x3e;
235 let Inst{39-32} = vsrc0;
236 let Inst{47-40} = vsrc1;
237 let Inst{55-48} = vsrc2;
238 let Inst{63-56} = vsrc3;
241 let Uses = [EXEC] in {
243 class VINTRPCommon <dag outs, dag ins, string asm, list<dag> pattern> :
244 InstSI <outs, ins, asm, pattern> {
246 // VINTRP instructions read parameter values from LDS, but these parameter
247 // values are stored outside of the LDS memory that is allocated to the
248 // shader for general purpose use.
250 // While it may be possible for ds_read/ds_write instructions to access
251 // the parameter values in LDS, this would essentially be an out-of-bounds
252 // memory access which we consider to be undefined behavior.
254 // So even though these instructions read memory, this memory is outside the
255 // addressable memory space for the shader, and we consider these instructions
259 let hasSideEffects = 0;
262 class EXPCommon<dag outs, dag ins, string asm, list<dag> pattern> :
263 InstSI<outs, ins, asm, pattern> {
266 let mayLoad = 0; // Set to 1 if done bit is set.
268 let UseNamedOperandTable = 1;
270 let SchedRW = [WriteExport];
273 } // End Uses = [EXEC]
275 class MIMG <dag outs, dag ins, string asm, list<dag> pattern> :
276 InstSI <outs, ins, asm, pattern> {
283 let UseNamedOperandTable = 1;
284 let hasSideEffects = 0; // XXX ????