11db9f3b2SDimitry Andric//===-- DSDIRInstructions.td - LDS/VDS Direct Instruction Definitions -----===// 21db9f3b2SDimitry Andric// 31db9f3b2SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 41db9f3b2SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 51db9f3b2SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 61db9f3b2SDimitry Andric// 71db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 81db9f3b2SDimitry Andric 91db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 101db9f3b2SDimitry Andric// LDSDIR/VDSDIR encoding (LDSDIR is gfx11, VDSDIR is gfx12+) 111db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 121db9f3b2SDimitry Andric 131db9f3b2SDimitry Andricclass LDSDIRe<bits<2> op, bit is_direct> : Enc32 { 141db9f3b2SDimitry Andric // encoding fields 151db9f3b2SDimitry Andric bits<2> attrchan; 161db9f3b2SDimitry Andric bits<6> attr; 171db9f3b2SDimitry Andric bits<4> waitvdst; 181db9f3b2SDimitry Andric bits<8> vdst; 191db9f3b2SDimitry Andric 201db9f3b2SDimitry Andric // encoding 211db9f3b2SDimitry Andric let Inst{31-24} = 0xce; // encoding 221db9f3b2SDimitry Andric let Inst{23-22} = 0x0; // reserved 231db9f3b2SDimitry Andric let Inst{21-20} = op; 241db9f3b2SDimitry Andric let Inst{19-16} = waitvdst; 251db9f3b2SDimitry Andric let Inst{15-10} = !if(is_direct, ?, attr); 261db9f3b2SDimitry Andric let Inst{9-8} = !if(is_direct, ?, attrchan); 271db9f3b2SDimitry Andric let Inst{7-0} = vdst; 281db9f3b2SDimitry Andric} 291db9f3b2SDimitry Andric 301db9f3b2SDimitry Andricclass VDSDIRe<bits<2> op, bit is_direct> : Enc32 { 311db9f3b2SDimitry Andric // encoding fields 321db9f3b2SDimitry Andric bits<2> attrchan; 331db9f3b2SDimitry Andric bits<6> attr; 341db9f3b2SDimitry Andric bits<4> waitvdst; 351db9f3b2SDimitry Andric bits<8> vdst; 361db9f3b2SDimitry Andric bits<1> waitvsrc; 371db9f3b2SDimitry Andric 381db9f3b2SDimitry Andric // encoding 391db9f3b2SDimitry Andric let Inst{31-24} = 0xce; // encoding 401db9f3b2SDimitry Andric let Inst{23} = waitvsrc; 411db9f3b2SDimitry Andric let Inst{22} = 0x0; // reserved 421db9f3b2SDimitry Andric let Inst{21-20} = op; 431db9f3b2SDimitry Andric let Inst{19-16} = waitvdst; 441db9f3b2SDimitry Andric let Inst{15-10} = !if(is_direct, ?, attr); 451db9f3b2SDimitry Andric let Inst{9-8} = !if(is_direct, ?, attrchan); 461db9f3b2SDimitry Andric let Inst{7-0} = vdst; 471db9f3b2SDimitry Andric} 481db9f3b2SDimitry Andric 491db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 501db9f3b2SDimitry Andric// LDSDIR/VDSDIR Classes 511db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 521db9f3b2SDimitry Andric 531db9f3b2SDimitry Andricclass LDSDIR_getIns<bit direct> { 541db9f3b2SDimitry Andric dag ret = !if(direct, 55*0fca6ea1SDimitry Andric (ins WaitVDST:$waitvdst), 56*0fca6ea1SDimitry Andric (ins InterpAttr:$attr, InterpAttrChan:$attrchan, WaitVDST:$waitvdst) 571db9f3b2SDimitry Andric ); 581db9f3b2SDimitry Andric} 591db9f3b2SDimitry Andric 601db9f3b2SDimitry Andricclass VDSDIR_getIns<bit direct> { 611db9f3b2SDimitry Andric dag ret = !if(direct, 62*0fca6ea1SDimitry Andric (ins WaitVAVDst:$waitvdst, WaitVMVSrc:$waitvsrc), 63*0fca6ea1SDimitry Andric (ins InterpAttr:$attr, InterpAttrChan:$attrchan, WaitVAVDst:$waitvdst, 64*0fca6ea1SDimitry Andric WaitVMVSrc:$waitvsrc) 651db9f3b2SDimitry Andric ); 661db9f3b2SDimitry Andric} 671db9f3b2SDimitry Andric 681db9f3b2SDimitry Andricclass DSDIR_Common<string opName, string asm = "", dag ins, bit direct> : 691db9f3b2SDimitry Andric InstSI<(outs VGPR_32:$vdst), ins, asm> { 701db9f3b2SDimitry Andric let LDSDIR = 1; 711db9f3b2SDimitry Andric let EXP_CNT = 1; 721db9f3b2SDimitry Andric 731db9f3b2SDimitry Andric let hasSideEffects = 0; 741db9f3b2SDimitry Andric let mayLoad = 1; 751db9f3b2SDimitry Andric let mayStore = 0; 761db9f3b2SDimitry Andric let maybeAtomic = 0; 771db9f3b2SDimitry Andric 781db9f3b2SDimitry Andric string Mnemonic = opName; 791db9f3b2SDimitry Andric let UseNamedOperandTable = 1; 801db9f3b2SDimitry Andric 811db9f3b2SDimitry Andric let Uses = [M0, EXEC]; 821db9f3b2SDimitry Andric let DisableWQM = 0; 831db9f3b2SDimitry Andric let SchedRW = [WriteLDS]; 841db9f3b2SDimitry Andric 851db9f3b2SDimitry Andric bit is_direct; 861db9f3b2SDimitry Andric let is_direct = direct; 871db9f3b2SDimitry Andric} 881db9f3b2SDimitry Andric 891db9f3b2SDimitry Andricclass DSDIR_Pseudo<string opName, dag ins, bit direct> : 901db9f3b2SDimitry Andric DSDIR_Common<opName, "", ins, direct>, 911db9f3b2SDimitry Andric SIMCInstr<opName, SIEncodingFamily.NONE> { 921db9f3b2SDimitry Andric let isPseudo = 1; 931db9f3b2SDimitry Andric let isCodeGenOnly = 1; 941db9f3b2SDimitry Andric} 951db9f3b2SDimitry Andric 961db9f3b2SDimitry Andricclass LDSDIR_getAsm<bit direct> { 971db9f3b2SDimitry Andric string ret = !if(direct, 981db9f3b2SDimitry Andric " $vdst$waitvdst", 991db9f3b2SDimitry Andric " $vdst, $attr$attrchan$waitvdst" 1001db9f3b2SDimitry Andric ); 1011db9f3b2SDimitry Andric} 1021db9f3b2SDimitry Andric 1031db9f3b2SDimitry Andricclass VDSDIR_getAsm<bit direct> { 1041db9f3b2SDimitry Andric string ret = !if(direct, 1051db9f3b2SDimitry Andric " $vdst$waitvdst$waitvsrc", 1061db9f3b2SDimitry Andric " $vdst, $attr$attrchan$waitvdst$waitvsrc" 1071db9f3b2SDimitry Andric ); 1081db9f3b2SDimitry Andric} 1091db9f3b2SDimitry Andric 1101db9f3b2SDimitry Andricclass DSDIR_Real<DSDIR_Pseudo lds, dag ins, string asm, int subtarget> : 1111db9f3b2SDimitry Andric DSDIR_Common<lds.Mnemonic, 1121db9f3b2SDimitry Andric lds.Mnemonic # asm, 1131db9f3b2SDimitry Andric ins, 1141db9f3b2SDimitry Andric lds.is_direct>, 115*0fca6ea1SDimitry Andric SIMCInstr <lds.PseudoInstr, subtarget> { 1161db9f3b2SDimitry Andric let isPseudo = 0; 1171db9f3b2SDimitry Andric let isCodeGenOnly = 0; 118*0fca6ea1SDimitry Andric 119*0fca6ea1SDimitry Andric // copy SubtargetPredicate from pseudo. 120*0fca6ea1SDimitry Andric let SubtargetPredicate = lds.SubtargetPredicate; 1211db9f3b2SDimitry Andric} 1221db9f3b2SDimitry Andric 1231db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 1241db9f3b2SDimitry Andric// LDS/VDS Direct Instructions 1251db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 1261db9f3b2SDimitry Andric 1271db9f3b2SDimitry Andriclet SubtargetPredicate = isGFX11Only in { 1281db9f3b2SDimitry Andric 1291db9f3b2SDimitry Andricdef LDS_DIRECT_LOAD : DSDIR_Pseudo<"lds_direct_load", LDSDIR_getIns<1>.ret, 1>; 1301db9f3b2SDimitry Andricdef LDS_PARAM_LOAD : DSDIR_Pseudo<"lds_param_load", LDSDIR_getIns<0>.ret, 0>; 1311db9f3b2SDimitry Andric 1321db9f3b2SDimitry Andricdef : GCNPat < 1331db9f3b2SDimitry Andric (f32 (int_amdgcn_lds_direct_load M0)), 1341db9f3b2SDimitry Andric (LDS_DIRECT_LOAD 0) 1351db9f3b2SDimitry Andric>; 1361db9f3b2SDimitry Andric 1371db9f3b2SDimitry Andricdef : GCNPat < 1381db9f3b2SDimitry Andric (f32 (int_amdgcn_lds_param_load timm:$attrchan, timm:$attr, M0)), 1391db9f3b2SDimitry Andric (LDS_PARAM_LOAD timm:$attr, timm:$attrchan, 0) 1401db9f3b2SDimitry Andric>; 1411db9f3b2SDimitry Andric 1421db9f3b2SDimitry Andric} // End SubtargetPredicate = isGFX11Only 1431db9f3b2SDimitry Andric 1441db9f3b2SDimitry Andriclet SubtargetPredicate = isGFX12Plus in { 1451db9f3b2SDimitry Andric 1461db9f3b2SDimitry Andricdef DS_DIRECT_LOAD : DSDIR_Pseudo<"ds_direct_load", VDSDIR_getIns<1>.ret, 1>; 1471db9f3b2SDimitry Andricdef DS_PARAM_LOAD : DSDIR_Pseudo<"ds_param_load", VDSDIR_getIns<0>.ret, 0>; 1481db9f3b2SDimitry Andric 1491db9f3b2SDimitry Andricdef : GCNPat < 1501db9f3b2SDimitry Andric (f32 (int_amdgcn_lds_direct_load M0)), 1511db9f3b2SDimitry Andric (DS_DIRECT_LOAD 0, 1) 1521db9f3b2SDimitry Andric>; 1531db9f3b2SDimitry Andric 1541db9f3b2SDimitry Andricdef : GCNPat < 1551db9f3b2SDimitry Andric (f32 (int_amdgcn_lds_param_load timm:$attrchan, timm:$attr, M0)), 1561db9f3b2SDimitry Andric (DS_PARAM_LOAD timm:$attr, timm:$attrchan, 0, 1) 1571db9f3b2SDimitry Andric>; 1581db9f3b2SDimitry Andric 1591db9f3b2SDimitry Andric} // End SubtargetPredicate = isGFX12Only 1601db9f3b2SDimitry Andric 1611db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 1621db9f3b2SDimitry Andric// GFX11 1631db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 1641db9f3b2SDimitry Andric 165*0fca6ea1SDimitry Andricmulticlass DSDIR_Real_gfx11<bits<2> op> { 166*0fca6ea1SDimitry Andric defvar lds = !cast<DSDIR_Pseudo>(NAME); 1671db9f3b2SDimitry Andric def _gfx11 : DSDIR_Real<lds, lds.InOperandList, 1681db9f3b2SDimitry Andric LDSDIR_getAsm<lds.is_direct>.ret, 1691db9f3b2SDimitry Andric SIEncodingFamily.GFX11>, 1701db9f3b2SDimitry Andric LDSDIRe<op, lds.is_direct> { 1711db9f3b2SDimitry Andric let AssemblerPredicate = isGFX11Only; 1721db9f3b2SDimitry Andric let DecoderNamespace = "GFX11"; 1731db9f3b2SDimitry Andric } 1741db9f3b2SDimitry Andric} 1751db9f3b2SDimitry Andric 1761db9f3b2SDimitry Andricdefm LDS_PARAM_LOAD : DSDIR_Real_gfx11<0x0>; 1771db9f3b2SDimitry Andricdefm LDS_DIRECT_LOAD : DSDIR_Real_gfx11<0x1>; 1781db9f3b2SDimitry Andric 1791db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 1801db9f3b2SDimitry Andric// GFX12+ 1811db9f3b2SDimitry Andric//===----------------------------------------------------------------------===// 1821db9f3b2SDimitry Andric 183*0fca6ea1SDimitry Andricmulticlass DSDIR_Real_gfx12<bits<2> op> { 184*0fca6ea1SDimitry Andric defvar lds = !cast<DSDIR_Pseudo>(NAME); 1851db9f3b2SDimitry Andric def _gfx12 : DSDIR_Real<lds, lds.InOperandList, 1861db9f3b2SDimitry Andric VDSDIR_getAsm<lds.is_direct>.ret, 1871db9f3b2SDimitry Andric SIEncodingFamily.GFX12>, 1881db9f3b2SDimitry Andric VDSDIRe<op, lds.is_direct> { 1891db9f3b2SDimitry Andric let AssemblerPredicate = isGFX12Plus; 1901db9f3b2SDimitry Andric let DecoderNamespace = "GFX12"; 1911db9f3b2SDimitry Andric } 1921db9f3b2SDimitry Andric} 1931db9f3b2SDimitry Andric 1941db9f3b2SDimitry Andricdefm DS_PARAM_LOAD : DSDIR_Real_gfx12<0x0>; 1951db9f3b2SDimitry Andricdefm DS_DIRECT_LOAD : DSDIR_Real_gfx12<0x1>; 196