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 class InstSI <dag outs, dag ins, string asm = "",
14 list<dag> pattern = []> :
15 AMDGPUInst<outs, ins, asm, pattern>, GCNPredicateControl {
16 // Low bits - basic encoding information.
20 // SALU instruction formats.
27 // VALU instruction formats.
37 // Memory instruction formats.
46 // Pseudo instruction formats.
47 field bit VGPRSpill = 0;
48 field bit SGPRSpill = 0;
50 // High bits - other information.
52 field bit EXP_CNT = 0;
53 field bit LGKM_CNT = 0;
55 // Whether WQM _must_ be enabled for this instruction.
58 // Whether WQM _must_ be disabled for this instruction.
59 field bit DisableWQM = 0;
61 field bit Gather4 = 0;
63 // Most sopk treat the immediate as a signed 16-bit, however some
64 // use it as unsigned.
65 field bit SOPKZext = 0;
67 // This is an s_store_dword* instruction that requires a cache flush
68 // on wave termination. It is necessary to distinguish from mayStore
69 // SMEM instructions like the cache flush ones.
70 field bit ScalarStore = 0;
72 // Whether the operands can be ignored when computing the
74 field bit FixedSize = 0;
76 // This bit tells the assembler to use the 32-bit encoding in case it
77 // is unable to infer the encoding from the operands.
78 field bit VOPAsmPrefer32Bit = 0;
80 // This bit indicates that this is a VOP3 opcode which supports op_sel
81 // modifier (gfx9 only).
82 field bit VOP3_OPSEL = 0;
84 // Is it possible for this instruction to be atomic?
85 field bit maybeAtomic = 0;
87 // This bit indicates that this is a VI instruction which is renamed
88 // in GFX9. Required for correct mapping from pseudo to MC.
89 field bit renamedInGFX9 = 0;
91 // This bit indicates that this has a floating point result type, so
92 // the clamp modifier has floating point semantics.
93 field bit FPClamp = 0;
95 // This bit indicates that instruction may support integer clamping
96 // which depends on GPU features.
97 field bit IntClamp = 0;
99 // This field indicates that the clamp applies to the low component
100 // of a packed output register.
101 field bit ClampLo = 0;
103 // This field indicates that the clamp applies to the high component
104 // of a packed output register.
105 field bit ClampHi = 0;
107 // This bit indicates that this is a packed VOP3P instruction
108 field bit IsPacked = 0;
110 // This bit indicates that this is a D16 buffer instruction.
111 field bit D16Buf = 0;
113 // This field indicates that FLAT instruction accesses FLAT_GLBL or
114 // FLAT_SCRATCH segment. Must be 0 for non-FLAT instructions.
115 field bit IsNonFlatSeg = 0;
117 // This bit indicates that this uses the floating point double precision
118 // rounding mode flags
119 field bit FPDPRounding = 0;
121 // Instruction is FP atomic.
122 field bit FPAtomic = 0;
124 // This bit indicates that this is one of MFMA instructions.
127 // This bit indicates that this is one of DOT instructions.
130 // These need to be kept in sync with the enum in SIInstrFlags.
131 let TSFlags{0} = SALU;
132 let TSFlags{1} = VALU;
134 let TSFlags{2} = SOP1;
135 let TSFlags{3} = SOP2;
136 let TSFlags{4} = SOPC;
137 let TSFlags{5} = SOPK;
138 let TSFlags{6} = SOPP;
140 let TSFlags{7} = VOP1;
141 let TSFlags{8} = VOP2;
142 let TSFlags{9} = VOPC;
143 let TSFlags{10} = VOP3;
144 let TSFlags{12} = VOP3P;
146 let TSFlags{13} = VINTRP;
147 let TSFlags{14} = SDWA;
148 let TSFlags{15} = DPP;
150 let TSFlags{16} = MUBUF;
151 let TSFlags{17} = MTBUF;
152 let TSFlags{18} = SMRD;
153 let TSFlags{19} = MIMG;
154 let TSFlags{20} = EXP;
155 let TSFlags{21} = FLAT;
156 let TSFlags{22} = DS;
158 let TSFlags{23} = VGPRSpill;
159 let TSFlags{24} = SGPRSpill;
161 let TSFlags{32} = VM_CNT;
162 let TSFlags{33} = EXP_CNT;
163 let TSFlags{34} = LGKM_CNT;
165 let TSFlags{35} = WQM;
166 let TSFlags{36} = DisableWQM;
167 let TSFlags{37} = Gather4;
169 let TSFlags{38} = SOPKZext;
170 let TSFlags{39} = ScalarStore;
171 let TSFlags{40} = FixedSize;
172 let TSFlags{41} = VOPAsmPrefer32Bit;
173 let TSFlags{42} = VOP3_OPSEL;
175 let TSFlags{43} = maybeAtomic;
176 let TSFlags{44} = renamedInGFX9;
178 let TSFlags{45} = FPClamp;
179 let TSFlags{46} = IntClamp;
180 let TSFlags{47} = ClampLo;
181 let TSFlags{48} = ClampHi;
183 let TSFlags{49} = IsPacked;
185 let TSFlags{50} = D16Buf;
187 let TSFlags{51} = IsNonFlatSeg;
189 let TSFlags{52} = FPDPRounding;
191 let TSFlags{53} = FPAtomic;
193 let TSFlags{54} = IsMAI;
195 let TSFlags{55} = IsDOT;
197 let SchedRW = [Write32Bit];
199 field bits<1> DisableSIDecoder = 0;
200 field bits<1> DisableVIDecoder = 0;
201 field bits<1> DisableDecoder = 0;
203 let isAsmParserOnly = !if(!eq(DisableDecoder{0}, {0}), 0, 1);
204 let AsmVariantName = AMDGPUAsmVariants.Default;
206 // Avoid changing source registers in a way that violates constant bus read limitations.
207 let hasExtraSrcRegAllocReq = !if(VOP1,1,!if(VOP2,1,!if(VOP3,1,!if(VOPC,1,!if(SDWA,1, !if(VALU,1,0))))));
210 class PseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
211 : InstSI<outs, ins, asm, pattern> {
213 let isCodeGenOnly = 1;
216 class SPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
217 : PseudoInstSI<outs, ins, pattern, asm> {
221 class VPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
222 : PseudoInstSI<outs, ins, pattern, asm> {
227 class CFPseudoInstSI<dag outs, dag ins, list<dag> pattern = [],
228 bit UseExec = 0, bit DefExec = 0> :
229 SPseudoInstSI<outs, ins, pattern> {
231 let Uses = !if(UseExec, [EXEC], []);
232 let Defs = !if(DefExec, [EXEC, SCC], [SCC]);
235 let hasSideEffects = 0;
248 class VOPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVOPDst">;
250 class VINTRPe <bits<2> op> : Enc32 {
256 let Inst{7-0} = vsrc;
257 let Inst{9-8} = attrchan;
258 let Inst{15-10} = attr;
259 let Inst{17-16} = op;
260 let Inst{25-18} = vdst;
261 let Inst{31-26} = 0x32; // encoding
264 class MIMGe : Enc64 {
277 let Inst{11-8} = dmask;
278 let Inst{12} = unorm;
284 let Inst{31-26} = 0x3c;
285 let Inst{47-40} = vdata;
286 let Inst{52-48} = srsrc{6-2};
287 let Inst{57-53} = ssamp{6-2};
291 class MIMGe_gfx6789 <bits<8> op> : MIMGe {
297 let Inst{24-18} = op{6-0};
298 let Inst{39-32} = vaddr;
301 class MIMGe_gfx10 <bits<8> op> : MIMGe {
306 bits<1> a16 = 0; // TODO: this should be an operand
312 let Inst{24-18} = op{6-0};
313 let Inst{39-32} = vaddr0;
330 let Inst{10} = compr;
333 let Inst{31-26} = 0x3e;
334 let Inst{39-32} = src0;
335 let Inst{47-40} = src1;
336 let Inst{55-48} = src2;
337 let Inst{63-56} = src3;
340 let Uses = [EXEC] in {
342 class VINTRPCommon <dag outs, dag ins, string asm, list<dag> pattern> :
343 InstSI <outs, ins, asm, pattern> {
345 // VINTRP instructions read parameter values from LDS, but these parameter
346 // values are stored outside of the LDS memory that is allocated to the
347 // shader for general purpose use.
349 // While it may be possible for ds_read/ds_write instructions to access
350 // the parameter values in LDS, this would essentially be an out-of-bounds
351 // memory access which we consider to be undefined behavior.
353 // So even though these instructions read memory, this memory is outside the
354 // addressable memory space for the shader, and we consider these instructions
358 let hasSideEffects = 0;
362 class EXPCommon<dag outs, dag ins, string asm, list<dag> pattern> :
363 InstSI<outs, ins, asm, pattern> {
366 let mayLoad = 0; // Set to 1 if done bit is set.
368 let UseNamedOperandTable = 1;
370 let SchedRW = [WriteExport];
373 } // End Uses = [EXEC]