1//===-- SIInstrFormats.td - SI Instruction Encodings ----------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// SI Instruction format definitions. 11// 12//===----------------------------------------------------------------------===// 13 14class InstSI <dag outs, dag ins, string asm = "", 15 list<dag> pattern = []> : 16 AMDGPUInst<outs, ins, asm, pattern>, PredicateControl { 17 18 field bits<1> VM_CNT = 0; 19 field bits<1> EXP_CNT = 0; 20 field bits<1> LGKM_CNT = 0; 21 22 field bits<1> SALU = 0; 23 field bits<1> VALU = 0; 24 25 field bits<1> SOP1 = 0; 26 field bits<1> SOP2 = 0; 27 field bits<1> SOPC = 0; 28 field bits<1> SOPK = 0; 29 field bits<1> SOPP = 0; 30 31 field bits<1> VOP1 = 0; 32 field bits<1> VOP2 = 0; 33 field bits<1> VOP3 = 0; 34 field bits<1> VOPC = 0; 35 field bits<1> SDWA = 0; 36 field bits<1> DPP = 0; 37 38 field bits<1> MUBUF = 0; 39 field bits<1> MTBUF = 0; 40 field bits<1> SMRD = 0; 41 field bits<1> DS = 0; 42 field bits<1> MIMG = 0; 43 field bits<1> FLAT = 0; 44 45 // Whether WQM _must_ be enabled for this instruction. 46 field bits<1> WQM = 0; 47 field bits<1> VGPRSpill = 0; 48 field bits<1> SGPRSpill = 0; 49 50 // This bit tells the assembler to use the 32-bit encoding in case it 51 // is unable to infer the encoding from the operands. 52 field bits<1> VOPAsmPrefer32Bit = 0; 53 54 field bits<1> Gather4 = 0; 55 56 // Whether WQM _must_ be disabled for this instruction. 57 field bits<1> DisableWQM = 0; 58 59 // Most sopk treat the immediate as a signed 16-bit, however some 60 // use it as unsigned. 61 field bits<1> SOPKZext = 0; 62 63 // These need to be kept in sync with the enum in SIInstrFlags. 64 let TSFlags{0} = VM_CNT; 65 let TSFlags{1} = EXP_CNT; 66 let TSFlags{2} = LGKM_CNT; 67 68 let TSFlags{3} = SALU; 69 let TSFlags{4} = VALU; 70 71 let TSFlags{5} = SOP1; 72 let TSFlags{6} = SOP2; 73 let TSFlags{7} = SOPC; 74 let TSFlags{8} = SOPK; 75 let TSFlags{9} = SOPP; 76 77 let TSFlags{10} = VOP1; 78 let TSFlags{11} = VOP2; 79 let TSFlags{12} = VOP3; 80 let TSFlags{13} = VOPC; 81 let TSFlags{14} = SDWA; 82 let TSFlags{15} = DPP; 83 84 let TSFlags{16} = MUBUF; 85 let TSFlags{17} = MTBUF; 86 let TSFlags{18} = SMRD; 87 let TSFlags{19} = DS; 88 let TSFlags{20} = MIMG; 89 let TSFlags{21} = FLAT; 90 let TSFlags{22} = WQM; 91 let TSFlags{23} = VGPRSpill; 92 let TSFlags{24} = SGPRSpill; 93 let TSFlags{25} = VOPAsmPrefer32Bit; 94 let TSFlags{26} = Gather4; 95 let TSFlags{27} = DisableWQM; 96 let TSFlags{28} = SOPKZext; 97 98 let SchedRW = [Write32Bit]; 99 100 field bits<1> DisableSIDecoder = 0; 101 field bits<1> DisableVIDecoder = 0; 102 field bits<1> DisableDecoder = 0; 103 104 let isAsmParserOnly = !if(!eq(DisableDecoder{0}, {0}), 0, 1); 105 let AsmVariantName = AMDGPUAsmVariants.Default; 106} 107 108class PseudoInstSI<dag outs, dag ins, list<dag> pattern = []> 109 : InstSI<outs, ins, "", pattern> { 110 let isPseudo = 1; 111 let isCodeGenOnly = 1; 112} 113 114class SPseudoInstSI<dag outs, dag ins, list<dag> pattern = []> 115 : PseudoInstSI<outs, ins, pattern> { 116 let SALU = 1; 117} 118 119class VPseudoInstSI<dag outs, dag ins, list<dag> pattern = []> 120 : PseudoInstSI<outs, ins, pattern> { 121 let VALU = 1; 122 let Uses = [EXEC]; 123} 124 125class CFPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], 126 bit UseExec = 0, bit DefExec = 0> : 127 SPseudoInstSI<outs, ins, pattern> { 128 129 let Uses = !if(UseExec, [EXEC], []); 130 let Defs = !if(DefExec, [EXEC, SCC], [SCC]); 131 let mayLoad = 0; 132 let mayStore = 0; 133 let hasSideEffects = 0; 134} 135 136class Enc32 { 137 field bits<32> Inst; 138 int Size = 4; 139} 140 141class Enc64 { 142 field bits<64> Inst; 143 int Size = 8; 144} 145 146class VOPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVOPDst">; 147 148class VINTRPe <bits<2> op> : Enc32 { 149 bits<8> vdst; 150 bits<8> vsrc; 151 bits<2> attrchan; 152 bits<6> attr; 153 154 let Inst{7-0} = vsrc; 155 let Inst{9-8} = attrchan; 156 let Inst{15-10} = attr; 157 let Inst{17-16} = op; 158 let Inst{25-18} = vdst; 159 let Inst{31-26} = 0x32; // encoding 160} 161 162class MIMGe <bits<7> op> : Enc64 { 163 bits<8> vdata; 164 bits<4> dmask; 165 bits<1> unorm; 166 bits<1> glc; 167 bits<1> da; 168 bits<1> r128; 169 bits<1> tfe; 170 bits<1> lwe; 171 bits<1> slc; 172 bits<8> vaddr; 173 bits<7> srsrc; 174 bits<7> ssamp; 175 176 let Inst{11-8} = dmask; 177 let Inst{12} = unorm; 178 let Inst{13} = glc; 179 let Inst{14} = da; 180 let Inst{15} = r128; 181 let Inst{16} = tfe; 182 let Inst{17} = lwe; 183 let Inst{24-18} = op; 184 let Inst{25} = slc; 185 let Inst{31-26} = 0x3c; 186 let Inst{39-32} = vaddr; 187 let Inst{47-40} = vdata; 188 let Inst{52-48} = srsrc{6-2}; 189 let Inst{57-53} = ssamp{6-2}; 190} 191 192class EXPe : Enc64 { 193 bits<4> en; 194 bits<6> tgt; 195 bits<1> compr; 196 bits<1> done; 197 bits<1> vm; 198 bits<8> vsrc0; 199 bits<8> vsrc1; 200 bits<8> vsrc2; 201 bits<8> vsrc3; 202 203 let Inst{3-0} = en; 204 let Inst{9-4} = tgt; 205 let Inst{10} = compr; 206 let Inst{11} = done; 207 let Inst{12} = vm; 208 let Inst{31-26} = 0x3e; 209 let Inst{39-32} = vsrc0; 210 let Inst{47-40} = vsrc1; 211 let Inst{55-48} = vsrc2; 212 let Inst{63-56} = vsrc3; 213} 214 215let Uses = [EXEC] in { 216 217class VINTRPCommon <dag outs, dag ins, string asm, list<dag> pattern> : 218 InstSI <outs, ins, asm, pattern> { 219 let mayLoad = 1; 220 let mayStore = 0; 221 let hasSideEffects = 0; 222} 223 224} // End Uses = [EXEC] 225 226class MIMG <dag outs, dag ins, string asm, list<dag> pattern> : 227 InstSI <outs, ins, asm, pattern> { 228 229 let VM_CNT = 1; 230 let EXP_CNT = 1; 231 let MIMG = 1; 232 let Uses = [EXEC]; 233 234 let UseNamedOperandTable = 1; 235 let hasSideEffects = 0; // XXX ???? 236} 237