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 def isGCN : Predicate<"Subtarget->getGeneration() "
15 ">= AMDGPUSubtarget::SOUTHERN_ISLANDS">,
16 AssemblerPredicate<"FeatureGCN">;
17 def isSI : Predicate<"Subtarget->getGeneration() "
18 "== AMDGPUSubtarget::SOUTHERN_ISLANDS">,
19 AssemblerPredicate<"FeatureSouthernIslands">;
22 class InstSI <dag outs, dag ins, string asm = "",
23 list<dag> pattern = []> :
24 AMDGPUInst<outs, ins, asm, pattern>, GCNPredicateControl {
25 let SubtargetPredicate = isGCN;
27 // Low bits - basic encoding information.
31 // SALU instruction formats.
38 // VALU instruction formats.
48 // Memory instruction formats.
57 // Pseudo instruction formats.
58 field bit VGPRSpill = 0;
59 field bit SGPRSpill = 0;
61 // High bits - other information.
63 field bit EXP_CNT = 0;
64 field bit LGKM_CNT = 0;
66 // Whether WQM _must_ be enabled for this instruction.
69 // Whether WQM _must_ be disabled for this instruction.
70 field bit DisableWQM = 0;
72 field bit Gather4 = 0;
74 // Most sopk treat the immediate as a signed 16-bit, however some
75 // use it as unsigned.
76 field bit SOPKZext = 0;
78 // This is an s_store_dword* instruction that requires a cache flush
79 // on wave termination. It is necessary to distinguish from mayStore
80 // SMEM instructions like the cache flush ones.
81 field bit ScalarStore = 0;
83 // Whether the operands can be ignored when computing the
85 field bit FixedSize = 0;
87 // This bit tells the assembler to use the 32-bit encoding in case it
88 // is unable to infer the encoding from the operands.
89 field bit VOPAsmPrefer32Bit = 0;
91 // This bit indicates that this is a VOP3 opcode which supports op_sel
92 // modifier (gfx9 only).
93 field bit VOP3_OPSEL = 0;
95 // Is it possible for this instruction to be atomic?
96 field bit maybeAtomic = 0;
98 // This bit indicates that this is a VI instruction which is renamed
99 // in GFX9. Required for correct mapping from pseudo to MC.
100 field bit renamedInGFX9 = 0;
102 // This bit indicates that this has a floating point result type, so
103 // the clamp modifier has floating point semantics.
104 field bit FPClamp = 0;
106 // This bit indicates that instruction may support integer clamping
107 // which depends on GPU features.
108 field bit IntClamp = 0;
110 // This field indicates that the clamp applies to the low component
111 // of a packed output register.
112 field bit ClampLo = 0;
114 // This field indicates that the clamp applies to the high component
115 // of a packed output register.
116 field bit ClampHi = 0;
118 // This bit indicates that this is a packed VOP3P instruction
119 field bit IsPacked = 0;
121 // This bit indicates that this is a D16 buffer instruction.
122 field bit D16Buf = 0;
124 // These need to be kept in sync with the enum in SIInstrFlags.
125 let TSFlags{0} = SALU;
126 let TSFlags{1} = VALU;
128 let TSFlags{2} = SOP1;
129 let TSFlags{3} = SOP2;
130 let TSFlags{4} = SOPC;
131 let TSFlags{5} = SOPK;
132 let TSFlags{6} = SOPP;
134 let TSFlags{7} = VOP1;
135 let TSFlags{8} = VOP2;
136 let TSFlags{9} = VOPC;
137 let TSFlags{10} = VOP3;
138 let TSFlags{12} = VOP3P;
140 let TSFlags{13} = VINTRP;
141 let TSFlags{14} = SDWA;
142 let TSFlags{15} = DPP;
144 let TSFlags{16} = MUBUF;
145 let TSFlags{17} = MTBUF;
146 let TSFlags{18} = SMRD;
147 let TSFlags{19} = MIMG;
148 let TSFlags{20} = EXP;
149 let TSFlags{21} = FLAT;
150 let TSFlags{22} = DS;
152 let TSFlags{23} = VGPRSpill;
153 let TSFlags{24} = SGPRSpill;
155 let TSFlags{32} = VM_CNT;
156 let TSFlags{33} = EXP_CNT;
157 let TSFlags{34} = LGKM_CNT;
159 let TSFlags{35} = WQM;
160 let TSFlags{36} = DisableWQM;
161 let TSFlags{37} = Gather4;
163 let TSFlags{38} = SOPKZext;
164 let TSFlags{39} = ScalarStore;
165 let TSFlags{40} = FixedSize;
166 let TSFlags{41} = VOPAsmPrefer32Bit;
167 let TSFlags{42} = VOP3_OPSEL;
169 let TSFlags{43} = maybeAtomic;
170 let TSFlags{44} = renamedInGFX9;
172 let TSFlags{45} = FPClamp;
173 let TSFlags{46} = IntClamp;
174 let TSFlags{47} = ClampLo;
175 let TSFlags{48} = ClampHi;
177 let TSFlags{49} = IsPacked;
179 let TSFlags{50} = D16Buf;
181 let SchedRW = [Write32Bit];
183 field bits<1> DisableSIDecoder = 0;
184 field bits<1> DisableVIDecoder = 0;
185 field bits<1> DisableDecoder = 0;
187 let isAsmParserOnly = !if(!eq(DisableDecoder{0}, {0}), 0, 1);
188 let AsmVariantName = AMDGPUAsmVariants.Default;
190 // Avoid changing source registers in a way that violates constant bus read limitations.
191 let hasExtraSrcRegAllocReq = !if(VOP1,1,!if(VOP2,1,!if(VOP3,1,!if(VOPC,1,!if(SDWA,1, !if(VALU,1,0))))));
194 class PseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
195 : InstSI<outs, ins, asm, pattern> {
197 let isCodeGenOnly = 1;
200 class SPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
201 : PseudoInstSI<outs, ins, pattern, asm> {
205 class VPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
206 : PseudoInstSI<outs, ins, pattern, asm> {
211 class CFPseudoInstSI<dag outs, dag ins, list<dag> pattern = [],
212 bit UseExec = 0, bit DefExec = 0> :
213 SPseudoInstSI<outs, ins, pattern> {
215 let Uses = !if(UseExec, [EXEC], []);
216 let Defs = !if(DefExec, [EXEC, SCC], [SCC]);
219 let hasSideEffects = 0;
232 class VOPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVOPDst">;
234 class VINTRPe <bits<2> op> : Enc32 {
240 let Inst{7-0} = vsrc;
241 let Inst{9-8} = attrchan;
242 let Inst{15-10} = attr;
243 let Inst{17-16} = op;
244 let Inst{25-18} = vdst;
245 let Inst{31-26} = 0x32; // encoding
248 class MIMGe <bits<7> op> : Enc64 {
263 let Inst{11-8} = dmask;
264 let Inst{12} = unorm;
270 let Inst{24-18} = op;
272 let Inst{31-26} = 0x3c;
273 let Inst{39-32} = vaddr;
274 let Inst{47-40} = vdata;
275 let Inst{52-48} = srsrc{6-2};
276 let Inst{57-53} = ssamp{6-2};
293 let Inst{10} = compr;
296 let Inst{31-26} = 0x3e;
297 let Inst{39-32} = src0;
298 let Inst{47-40} = src1;
299 let Inst{55-48} = src2;
300 let Inst{63-56} = src3;
303 let Uses = [EXEC] in {
305 class VINTRPCommon <dag outs, dag ins, string asm, list<dag> pattern> :
306 InstSI <outs, ins, asm, pattern> {
308 // VINTRP instructions read parameter values from LDS, but these parameter
309 // values are stored outside of the LDS memory that is allocated to the
310 // shader for general purpose use.
312 // While it may be possible for ds_read/ds_write instructions to access
313 // the parameter values in LDS, this would essentially be an out-of-bounds
314 // memory access which we consider to be undefined behavior.
316 // So even though these instructions read memory, this memory is outside the
317 // addressable memory space for the shader, and we consider these instructions
321 let hasSideEffects = 0;
325 class EXPCommon<dag outs, dag ins, string asm, list<dag> pattern> :
326 InstSI<outs, ins, asm, pattern> {
329 let mayLoad = 0; // Set to 1 if done bit is set.
331 let UseNamedOperandTable = 1;
333 let SchedRW = [WriteExport];
336 } // End Uses = [EXEC]