1 //===-- SIInstrFormats.td - SI Instruction Encodings ----------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // SI Instruction format definitions.
11 //===----------------------------------------------------------------------===//
13 def isSI : Predicate<"Subtarget->getGeneration() "
14 "== AMDGPUSubtarget::SOUTHERN_ISLANDS">,
15 AssemblerPredicate<"FeatureSouthernIslands">;
18 class InstSI <dag outs, dag ins, string asm = "",
19 list<dag> pattern = []> :
20 AMDGPUInst<outs, ins, asm, pattern>, GCNPredicateControl {
21 // Low bits - basic encoding information.
25 // SALU instruction formats.
32 // VALU instruction formats.
42 // Memory instruction formats.
51 // Pseudo instruction formats.
52 field bit VGPRSpill = 0;
53 field bit SGPRSpill = 0;
55 // High bits - other information.
57 field bit EXP_CNT = 0;
58 field bit LGKM_CNT = 0;
60 // Whether WQM _must_ be enabled for this instruction.
63 // Whether WQM _must_ be disabled for this instruction.
64 field bit DisableWQM = 0;
66 field bit Gather4 = 0;
68 // Most sopk treat the immediate as a signed 16-bit, however some
69 // use it as unsigned.
70 field bit SOPKZext = 0;
72 // This is an s_store_dword* instruction that requires a cache flush
73 // on wave termination. It is necessary to distinguish from mayStore
74 // SMEM instructions like the cache flush ones.
75 field bit ScalarStore = 0;
77 // Whether the operands can be ignored when computing the
79 field bit FixedSize = 0;
81 // This bit tells the assembler to use the 32-bit encoding in case it
82 // is unable to infer the encoding from the operands.
83 field bit VOPAsmPrefer32Bit = 0;
85 // This bit indicates that this is a VOP3 opcode which supports op_sel
86 // modifier (gfx9 only).
87 field bit VOP3_OPSEL = 0;
89 // Is it possible for this instruction to be atomic?
90 field bit maybeAtomic = 0;
92 // This bit indicates that this is a VI instruction which is renamed
93 // in GFX9. Required for correct mapping from pseudo to MC.
94 field bit renamedInGFX9 = 0;
96 // This bit indicates that this has a floating point result type, so
97 // the clamp modifier has floating point semantics.
98 field bit FPClamp = 0;
100 // This bit indicates that instruction may support integer clamping
101 // which depends on GPU features.
102 field bit IntClamp = 0;
104 // This field indicates that the clamp applies to the low component
105 // of a packed output register.
106 field bit ClampLo = 0;
108 // This field indicates that the clamp applies to the high component
109 // of a packed output register.
110 field bit ClampHi = 0;
112 // This bit indicates that this is a packed VOP3P instruction
113 field bit IsPacked = 0;
115 // This bit indicates that this is a D16 buffer instruction.
116 field bit D16Buf = 0;
118 // This bit indicates that this uses the floating point double precision
119 // rounding mode flags
120 field bit FPDPRounding = 0;
122 // These need to be kept in sync with the enum in SIInstrFlags.
123 let TSFlags{0} = SALU;
124 let TSFlags{1} = VALU;
126 let TSFlags{2} = SOP1;
127 let TSFlags{3} = SOP2;
128 let TSFlags{4} = SOPC;
129 let TSFlags{5} = SOPK;
130 let TSFlags{6} = SOPP;
132 let TSFlags{7} = VOP1;
133 let TSFlags{8} = VOP2;
134 let TSFlags{9} = VOPC;
135 let TSFlags{10} = VOP3;
136 let TSFlags{12} = VOP3P;
138 let TSFlags{13} = VINTRP;
139 let TSFlags{14} = SDWA;
140 let TSFlags{15} = DPP;
142 let TSFlags{16} = MUBUF;
143 let TSFlags{17} = MTBUF;
144 let TSFlags{18} = SMRD;
145 let TSFlags{19} = MIMG;
146 let TSFlags{20} = EXP;
147 let TSFlags{21} = FLAT;
148 let TSFlags{22} = DS;
150 let TSFlags{23} = VGPRSpill;
151 let TSFlags{24} = SGPRSpill;
153 let TSFlags{32} = VM_CNT;
154 let TSFlags{33} = EXP_CNT;
155 let TSFlags{34} = LGKM_CNT;
157 let TSFlags{35} = WQM;
158 let TSFlags{36} = DisableWQM;
159 let TSFlags{37} = Gather4;
161 let TSFlags{38} = SOPKZext;
162 let TSFlags{39} = ScalarStore;
163 let TSFlags{40} = FixedSize;
164 let TSFlags{41} = VOPAsmPrefer32Bit;
165 let TSFlags{42} = VOP3_OPSEL;
167 let TSFlags{43} = maybeAtomic;
168 let TSFlags{44} = renamedInGFX9;
170 let TSFlags{45} = FPClamp;
171 let TSFlags{46} = IntClamp;
172 let TSFlags{47} = ClampLo;
173 let TSFlags{48} = ClampHi;
175 let TSFlags{49} = IsPacked;
177 let TSFlags{50} = D16Buf;
179 let TSFlags{51} = FPDPRounding;
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]