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.
39 // Memory instruction formats.
48 // Pseudo instruction formats.
49 field bit VGPRSpill = 0;
50 field bit SGPRSpill = 0;
52 // High bits - other information.
54 field bit EXP_CNT = 0;
55 field bit LGKM_CNT = 0;
57 // Whether WQM _must_ be enabled for this instruction.
60 // Whether WQM _must_ be disabled for this instruction.
61 field bit DisableWQM = 0;
63 field bit Gather4 = 0;
65 // Most sopk treat the immediate as a signed 16-bit, however some
66 // use it as unsigned.
67 field bit SOPKZext = 0;
69 // This is an s_store_dword* instruction that requires a cache flush
70 // on wave termination. It is necessary to distinguish from mayStore
71 // SMEM instructions like the cache flush ones.
72 field bit ScalarStore = 0;
74 // Whether the operands can be ignored when computing the
76 field bit FixedSize = 0;
78 // This bit tells the assembler to use the 32-bit encoding in case it
79 // is unable to infer the encoding from the operands.
80 field bit VOPAsmPrefer32Bit = 0;
82 // This bit indicates that this has a floating point result type, so
83 // the clamp modifier has floating point semantics.
84 field bit FPClamp = 0;
86 // These need to be kept in sync with the enum in SIInstrFlags.
87 let TSFlags{0} = SALU;
88 let TSFlags{1} = VALU;
90 let TSFlags{2} = SOP1;
91 let TSFlags{3} = SOP2;
92 let TSFlags{4} = SOPC;
93 let TSFlags{5} = SOPK;
94 let TSFlags{6} = SOPP;
96 let TSFlags{7} = VOP1;
97 let TSFlags{8} = VOP2;
98 let TSFlags{9} = VOPC;
99 let TSFlags{10} = VOP3;
100 let TSFlags{12} = VOP3P;
102 let TSFlags{13} = VINTRP;
103 let TSFlags{14} = SDWA;
104 let TSFlags{15} = DPP;
106 let TSFlags{16} = MUBUF;
107 let TSFlags{17} = MTBUF;
108 let TSFlags{18} = SMRD;
109 let TSFlags{19} = MIMG;
110 let TSFlags{20} = EXP;
111 let TSFlags{21} = FLAT;
112 let TSFlags{22} = DS;
114 let TSFlags{23} = VGPRSpill;
115 let TSFlags{24} = SGPRSpill;
117 let TSFlags{32} = VM_CNT;
118 let TSFlags{33} = EXP_CNT;
119 let TSFlags{34} = LGKM_CNT;
121 let TSFlags{35} = WQM;
122 let TSFlags{36} = DisableWQM;
123 let TSFlags{37} = Gather4;
125 let TSFlags{38} = SOPKZext;
126 let TSFlags{39} = ScalarStore;
127 let TSFlags{40} = FixedSize;
128 let TSFlags{41} = VOPAsmPrefer32Bit;
129 let TSFlags{42} = FPClamp;
131 let SchedRW = [Write32Bit];
133 field bits<1> DisableSIDecoder = 0;
134 field bits<1> DisableVIDecoder = 0;
135 field bits<1> DisableDecoder = 0;
137 let isAsmParserOnly = !if(!eq(DisableDecoder{0}, {0}), 0, 1);
138 let AsmVariantName = AMDGPUAsmVariants.Default;
141 class PseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
142 : InstSI<outs, ins, asm, pattern> {
144 let isCodeGenOnly = 1;
147 class SPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
148 : PseudoInstSI<outs, ins, pattern, asm> {
152 class VPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
153 : PseudoInstSI<outs, ins, pattern, asm> {
158 class CFPseudoInstSI<dag outs, dag ins, list<dag> pattern = [],
159 bit UseExec = 0, bit DefExec = 0> :
160 SPseudoInstSI<outs, ins, pattern> {
162 let Uses = !if(UseExec, [EXEC], []);
163 let Defs = !if(DefExec, [EXEC, SCC], [SCC]);
166 let hasSideEffects = 0;
179 class VOPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVOPDst">;
181 class VINTRPe <bits<2> op> : Enc32 {
187 let Inst{7-0} = vsrc;
188 let Inst{9-8} = attrchan;
189 let Inst{15-10} = attr;
190 let Inst{17-16} = op;
191 let Inst{25-18} = vdst;
192 let Inst{31-26} = 0x32; // encoding
195 class MIMGe <bits<7> op> : Enc64 {
209 let Inst{11-8} = dmask;
210 let Inst{12} = unorm;
216 let Inst{24-18} = op;
218 let Inst{31-26} = 0x3c;
219 let Inst{39-32} = vaddr;
220 let Inst{47-40} = vdata;
221 let Inst{52-48} = srsrc{6-2};
222 let Inst{57-53} = ssamp{6-2};
238 let Inst{10} = compr;
241 let Inst{31-26} = 0x3e;
242 let Inst{39-32} = src0;
243 let Inst{47-40} = src1;
244 let Inst{55-48} = src2;
245 let Inst{63-56} = src3;
248 let Uses = [EXEC] in {
250 class VINTRPCommon <dag outs, dag ins, string asm, list<dag> pattern> :
251 InstSI <outs, ins, asm, pattern> {
253 // VINTRP instructions read parameter values from LDS, but these parameter
254 // values are stored outside of the LDS memory that is allocated to the
255 // shader for general purpose use.
257 // While it may be possible for ds_read/ds_write instructions to access
258 // the parameter values in LDS, this would essentially be an out-of-bounds
259 // memory access which we consider to be undefined behavior.
261 // So even though these instructions read memory, this memory is outside the
262 // addressable memory space for the shader, and we consider these instructions
266 let hasSideEffects = 0;
269 class EXPCommon<dag outs, dag ins, string asm, list<dag> pattern> :
270 InstSI<outs, ins, asm, pattern> {
273 let mayLoad = 0; // Set to 1 if done bit is set.
275 let UseNamedOperandTable = 1;
277 let SchedRW = [WriteExport];
280 } // End Uses = [EXEC]
282 class MIMG <dag outs, dag ins, string asm, list<dag> pattern> :
283 InstSI <outs, ins, asm, pattern> {
290 let UseNamedOperandTable = 1;
291 let hasSideEffects = 0; // XXX ????