15ffd83dbSDimitry Andric//===-- BUFInstructions.td - Buffer Instruction Definitions ---------------===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90eae32dcSDimitry Andricdef MUBUFAddr64 : ComplexPattern<iPTR, 4, "SelectMUBUFAddr64">; 100eae32dcSDimitry Andricdef MUBUFOffset : ComplexPattern<iPTR, 3, "SelectMUBUFOffset">; 110b57cec5SDimitry Andric 120eae32dcSDimitry Andricdef MUBUFScratchOffen : ComplexPattern<iPTR, 4, "SelectMUBUFScratchOffen", [], [SDNPWantParent]>; 130eae32dcSDimitry Andricdef MUBUFScratchOffset : ComplexPattern<iPTR, 3, "SelectMUBUFScratchOffset", [], [SDNPWantParent], 20>; 140b57cec5SDimitry Andric 155f757f3fSDimitry Andricdef BUFSOffset : ComplexPattern<iPTR, 1, "SelectBUFSOffset">; 165f757f3fSDimitry Andric 170b57cec5SDimitry Andricdef BUFAddrKind { 180b57cec5SDimitry Andric int Offset = 0; 190b57cec5SDimitry Andric int OffEn = 1; 200b57cec5SDimitry Andric int IdxEn = 2; 210b57cec5SDimitry Andric int BothEn = 3; 220b57cec5SDimitry Andric int Addr64 = 4; 230b57cec5SDimitry Andric} 240b57cec5SDimitry Andric 250b57cec5SDimitry Andricclass getAddrName<int addrKind> { 260b57cec5SDimitry Andric string ret = 270b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Offset), "offset", 280b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.OffEn), "offen", 290b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.IdxEn), "idxen", 300b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.BothEn), "bothen", 310b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Addr64), "addr64", 320b57cec5SDimitry Andric ""))))); 330b57cec5SDimitry Andric} 340b57cec5SDimitry Andric 350b57cec5SDimitry Andricclass MUBUFAddr64Table <bit is_addr64, string Name> { 360b57cec5SDimitry Andric bit IsAddr64 = is_addr64; 370b57cec5SDimitry Andric string OpName = Name; 380b57cec5SDimitry Andric} 390b57cec5SDimitry Andric 400b57cec5SDimitry Andricclass MTBUFAddr64Table <bit is_addr64, string Name> { 410b57cec5SDimitry Andric bit IsAddr64 = is_addr64; 420b57cec5SDimitry Andric string OpName = Name; 430b57cec5SDimitry Andric} 440b57cec5SDimitry Andric 45bdd1243dSDimitry Andric 460b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 47bdd1243dSDimitry Andric// BUF class (base class for MTBUF and MUBUF pseudos) 480b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 490b57cec5SDimitry Andric 50bdd1243dSDimitry Andricclass BUF_Pseudo <string opName, dag outs, dag ins, 510b57cec5SDimitry Andric string asmOps, list<dag> pattern=[]> : 520b57cec5SDimitry Andric InstSI<outs, ins, "", pattern>, 530b57cec5SDimitry Andric SIMCInstr<opName, SIEncodingFamily.NONE> { 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric let isPseudo = 1; 560b57cec5SDimitry Andric let isCodeGenOnly = 1; 570b57cec5SDimitry Andric let Size = 8; 580b57cec5SDimitry Andric let UseNamedOperandTable = 1; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric string Mnemonic = opName; 610b57cec5SDimitry Andric string AsmOperands = asmOps; 620b57cec5SDimitry Andric 638bcb0991SDimitry Andric Instruction Opcode = !cast<Instruction>(NAME); 64bdd1243dSDimitry Andric 658bcb0991SDimitry Andric 660b57cec5SDimitry Andric let VM_CNT = 1; 670b57cec5SDimitry Andric let EXP_CNT = 1; 68bdd1243dSDimitry Andric 690b57cec5SDimitry Andric let Uses = [EXEC]; 700b57cec5SDimitry Andric let hasSideEffects = 0; 710b57cec5SDimitry Andric let SchedRW = [WriteVMEM]; 720b57cec5SDimitry Andric 73bdd1243dSDimitry Andric 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric bits<1> offen = 0; 760b57cec5SDimitry Andric bits<1> idxen = 0; 770b57cec5SDimitry Andric bits<1> addr64 = 0; 78bdd1243dSDimitry Andric bits<1> lds = 0; 79bdd1243dSDimitry Andric bits<1> has_vdata = !not(lds); 800b57cec5SDimitry Andric bits<1> has_vaddr = 1; 810b57cec5SDimitry Andric bits<1> has_glc = 1; 820b57cec5SDimitry Andric bits<1> has_dlc = 1; 830b57cec5SDimitry Andric bits<1> glc_value = 0; // the value for glc if no such operand 840b57cec5SDimitry Andric bits<1> dlc_value = 0; // the value for dlc if no such operand 850b57cec5SDimitry Andric bits<1> has_srsrc = 1; 860b57cec5SDimitry Andric bits<1> has_soffset = 1; 870b57cec5SDimitry Andric bits<1> has_offset = 1; 880b57cec5SDimitry Andric bits<1> has_slc = 1; 89*0fca6ea1SDimitry Andric bits<1> tfe = 0; 908bcb0991SDimitry Andric bits<4> elements = 0; 91fe6060f1SDimitry Andric bits<1> has_sccb = 1; 92fe6060f1SDimitry Andric bits<1> sccb_value = 0; 93bdd1243dSDimitry Andric bits<1> IsBufferInv = 0; 94bdd1243dSDimitry Andric} 95bdd1243dSDimitry Andric 96bdd1243dSDimitry Andric 97bdd1243dSDimitry Andric 98bdd1243dSDimitry Andric//===----------------------------------------------------------------------===// 99bdd1243dSDimitry Andric// MTBUF classes 100bdd1243dSDimitry Andric//===----------------------------------------------------------------------===// 101bdd1243dSDimitry Andric 102bdd1243dSDimitry Andricclass MTBUFGetBaseOpcode<string Op> { 103bdd1243dSDimitry Andric string ret = !subst("FORMAT_XY", "FORMAT_X", 104bdd1243dSDimitry Andric !subst("FORMAT_XYZ", "FORMAT_X", 105bdd1243dSDimitry Andric !subst("FORMAT_XYZW", "FORMAT_X", Op))); 106bdd1243dSDimitry Andric} 107bdd1243dSDimitry Andric 108bdd1243dSDimitry Andric 109bdd1243dSDimitry Andricclass MTBUF_Pseudo <string opName, dag outs, dag ins, 110bdd1243dSDimitry Andric string asmOps, list<dag> pattern=[]> : 111bdd1243dSDimitry Andric BUF_Pseudo <opName, outs, ins, asmOps, pattern> { 112bdd1243dSDimitry Andric 113bdd1243dSDimitry Andric Instruction BaseOpcode = !cast<Instruction>(MTBUFGetBaseOpcode<NAME>.ret); 114bdd1243dSDimitry Andric let MTBUF = 1; 1150b57cec5SDimitry Andric} 1160b57cec5SDimitry Andric 11781ad6265SDimitry Andricclass MTBUF_Real <MTBUF_Pseudo ps, string real_name = ps.Mnemonic> : 11881ad6265SDimitry Andric InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []> { 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric let isPseudo = 0; 1210b57cec5SDimitry Andric let isCodeGenOnly = 0; 1220b57cec5SDimitry Andric 123fe6060f1SDimitry Andric let VM_CNT = 1; 124fe6060f1SDimitry Andric let EXP_CNT = 1; 125fe6060f1SDimitry Andric let MTBUF = 1; 126fe6060f1SDimitry Andric 1270b57cec5SDimitry Andric // copy relevant pseudo op flags 128e8d8bef9SDimitry Andric let UseNamedOperandTable = ps.UseNamedOperandTable; 1290b57cec5SDimitry Andric let SubtargetPredicate = ps.SubtargetPredicate; 130*0fca6ea1SDimitry Andric let OtherPredicates = ps.OtherPredicates; 1310b57cec5SDimitry Andric let AsmMatchConverter = ps.AsmMatchConverter; 1320b57cec5SDimitry Andric let Constraints = ps.Constraints; 1330b57cec5SDimitry Andric let DisableEncoding = ps.DisableEncoding; 1340b57cec5SDimitry Andric let TSFlags = ps.TSFlags; 135fe6060f1SDimitry Andric let SchedRW = ps.SchedRW; 136fe6060f1SDimitry Andric let mayLoad = ps.mayLoad; 137fe6060f1SDimitry Andric let mayStore = ps.mayStore; 138fe6060f1SDimitry Andric let IsAtomicRet = ps.IsAtomicRet; 139fe6060f1SDimitry Andric let IsAtomicNoRet = ps.IsAtomicNoRet; 140*0fca6ea1SDimitry Andric let Uses = ps.Uses; 141*0fca6ea1SDimitry Andric let Defs = ps.Defs; 1420b57cec5SDimitry Andric 1430b57cec5SDimitry Andric bits<12> offset; 144fe6060f1SDimitry Andric bits<5> cpol; 1450b57cec5SDimitry Andric bits<7> format; 1460b57cec5SDimitry Andric bits<8> vaddr; 147fe6060f1SDimitry Andric bits<10> vdata; 1480b57cec5SDimitry Andric bits<7> srsrc; 1490b57cec5SDimitry Andric bits<8> soffset; 1500b57cec5SDimitry Andric 1510b57cec5SDimitry Andric bits<4> dfmt = format{3-0}; 1520b57cec5SDimitry Andric bits<3> nfmt = format{6-4}; 153fe6060f1SDimitry Andric 154fe6060f1SDimitry Andric // GFX90A+ only: instruction uses AccVGPR for data 15581ad6265SDimitry Andric // Bit supersedes tfe. 156fe6060f1SDimitry Andric bits<1> acc = !if(ps.has_vdata, vdata{9}, 0); 1570b57cec5SDimitry Andric} 1580b57cec5SDimitry Andric 1590b57cec5SDimitry Andricclass getMTBUFInsDA<list<RegisterClass> vdataList, 160*0fca6ea1SDimitry Andric list<RegisterClass> vaddrList=[], bit hasRestrictedSOffset> { 1610b57cec5SDimitry Andric RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList)); 1620b57cec5SDimitry Andric RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList)); 163fe6060f1SDimitry Andric RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret; 164bdd1243dSDimitry Andric 165*0fca6ea1SDimitry Andric dag SOffset = !if(hasRestrictedSOffset, (ins SReg_32:$soffset), 1665f757f3fSDimitry Andric (ins SCSrc_b32:$soffset)); 1675f757f3fSDimitry Andric 1685f757f3fSDimitry Andric dag NonVaddrInputs = !con((ins SReg_128:$srsrc), SOffset, 169*0fca6ea1SDimitry Andric (ins Offset:$offset, FORMAT:$format, CPol_0:$cpol, i1imm_0:$swz)); 1705f757f3fSDimitry Andric 1715f757f3fSDimitry Andric dag Inputs = !if(!empty(vaddrList), 1725f757f3fSDimitry Andric NonVaddrInputs, 1735f757f3fSDimitry Andric !con((ins vaddrClass:$vaddr), NonVaddrInputs)); 1745f757f3fSDimitry Andric dag ret = !if(!empty(vdataList), 1755f757f3fSDimitry Andric Inputs, 1765f757f3fSDimitry Andric !con((ins vdata_op:$vdata), Inputs)); 1770b57cec5SDimitry Andric} 1780b57cec5SDimitry Andric 179*0fca6ea1SDimitry Andricclass getMTBUFIns<int addrKind, list<RegisterClass> vdataList=[], bit hasRestrictedSOffset> { 1800b57cec5SDimitry Andric dag ret = 181*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Offset), getMTBUFInsDA<vdataList, [], hasRestrictedSOffset>.ret, 182*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.OffEn), getMTBUFInsDA<vdataList, [VGPR_32], hasRestrictedSOffset>.ret, 183*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.IdxEn), getMTBUFInsDA<vdataList, [VGPR_32], hasRestrictedSOffset>.ret, 184*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.BothEn), getMTBUFInsDA<vdataList, [VReg_64], hasRestrictedSOffset>.ret, 185*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Addr64), getMTBUFInsDA<vdataList, [VReg_64], hasRestrictedSOffset>.ret, 1860b57cec5SDimitry Andric (ins)))))); 1870b57cec5SDimitry Andric} 1880b57cec5SDimitry Andric 1890b57cec5SDimitry Andricclass getMTBUFAsmOps<int addrKind> { 1900b57cec5SDimitry Andric string Pfx = 191e8d8bef9SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc,$format $soffset", 1920b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.OffEn), 193e8d8bef9SDimitry Andric "$vaddr, $srsrc,$format $soffset offen", 1940b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.IdxEn), 195e8d8bef9SDimitry Andric "$vaddr, $srsrc,$format $soffset idxen", 1960b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.BothEn), 197e8d8bef9SDimitry Andric "$vaddr, $srsrc,$format $soffset idxen offen", 1980b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Addr64), 199e8d8bef9SDimitry Andric "$vaddr, $srsrc,$format $soffset addr64", 2000b57cec5SDimitry Andric ""))))); 20106c3fb27SDimitry Andric string ret = " $vdata, " # Pfx # "$offset$cpol"; 2020b57cec5SDimitry Andric} 2030b57cec5SDimitry Andric 2040b57cec5SDimitry Andricclass MTBUF_SetupAddr<int addrKind> { 205e8d8bef9SDimitry Andric bits<1> offen = !or(!eq(addrKind, BUFAddrKind.OffEn), 206e8d8bef9SDimitry Andric !eq(addrKind, BUFAddrKind.BothEn)); 2070b57cec5SDimitry Andric 208e8d8bef9SDimitry Andric bits<1> idxen = !or(!eq(addrKind, BUFAddrKind.IdxEn), 209e8d8bef9SDimitry Andric !eq(addrKind, BUFAddrKind.BothEn)); 2100b57cec5SDimitry Andric 211e8d8bef9SDimitry Andric bits<1> addr64 = !eq(addrKind, BUFAddrKind.Addr64); 2120b57cec5SDimitry Andric 213e8d8bef9SDimitry Andric bits<1> has_vaddr = !ne(addrKind, BUFAddrKind.Offset); 2140b57cec5SDimitry Andric} 2150b57cec5SDimitry Andric 2160b57cec5SDimitry Andricclass MTBUF_Load_Pseudo <string opName, 2170b57cec5SDimitry Andric int addrKind, 2180b57cec5SDimitry Andric RegisterClass vdataClass, 2198bcb0991SDimitry Andric int elems, 220*0fca6ea1SDimitry Andric bit hasRestrictedSOffset = 0, 2210b57cec5SDimitry Andric list<dag> pattern=[], 2220b57cec5SDimitry Andric // Workaround bug bz30254 2230b57cec5SDimitry Andric int addrKindCopy = addrKind> 2240b57cec5SDimitry Andric : MTBUF_Pseudo<opName, 225fe6060f1SDimitry Andric (outs getLdStRegisterOperand<vdataClass>.ret:$vdata), 226*0fca6ea1SDimitry Andric getMTBUFIns<addrKindCopy, [], hasRestrictedSOffset>.ret, 227bdd1243dSDimitry Andric getMTBUFAsmOps<addrKindCopy>.ret, 2280b57cec5SDimitry Andric pattern>, 2290b57cec5SDimitry Andric MTBUF_SetupAddr<addrKindCopy> { 2300b57cec5SDimitry Andric let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret; 2310b57cec5SDimitry Andric let mayLoad = 1; 2320b57cec5SDimitry Andric let mayStore = 0; 2338bcb0991SDimitry Andric let elements = elems; 2340b57cec5SDimitry Andric} 2350b57cec5SDimitry Andric 2365f757f3fSDimitry Andricmulticlass MTBUF_Pseudo_Loads_Helper<string opName, RegisterClass vdataClass, 237*0fca6ea1SDimitry Andric int elems, bit hasRestrictedSOffset> { 2380b57cec5SDimitry Andric 239*0fca6ea1SDimitry Andric def _OFFSET : MTBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems, hasRestrictedSOffset>, 2400b57cec5SDimitry Andric MTBUFAddr64Table<0, NAME>; 2410b57cec5SDimitry Andric 242*0fca6ea1SDimitry Andric def _ADDR64 : MTBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, elems, hasRestrictedSOffset>, 2430b57cec5SDimitry Andric MTBUFAddr64Table<1, NAME>; 2440b57cec5SDimitry Andric 245*0fca6ea1SDimitry Andric def _OFFEN : MTBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems, hasRestrictedSOffset>; 246*0fca6ea1SDimitry Andric def _IDXEN : MTBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems, hasRestrictedSOffset>; 247*0fca6ea1SDimitry Andric def _BOTHEN : MTBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems, hasRestrictedSOffset>; 2480b57cec5SDimitry Andric 2490b57cec5SDimitry Andric let DisableWQM = 1 in { 250*0fca6ea1SDimitry Andric def _OFFSET_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems, hasRestrictedSOffset>; 251*0fca6ea1SDimitry Andric def _OFFEN_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems, hasRestrictedSOffset>; 252*0fca6ea1SDimitry Andric def _IDXEN_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems, hasRestrictedSOffset>; 253*0fca6ea1SDimitry Andric def _BOTHEN_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems, hasRestrictedSOffset>; 2540b57cec5SDimitry Andric } 2550b57cec5SDimitry Andric} 2560b57cec5SDimitry Andric 2575f757f3fSDimitry Andricmulticlass MTBUF_Pseudo_Loads<string opName, RegisterClass vdataClass, 2585f757f3fSDimitry Andric int elems> { 2595f757f3fSDimitry Andric defm NAME : MTBUF_Pseudo_Loads_Helper<opName, vdataClass, elems, 0>; 2605f757f3fSDimitry Andric defm _VBUFFER : MTBUF_Pseudo_Loads_Helper<opName, vdataClass, elems, 1>; 2615f757f3fSDimitry Andric} 2625f757f3fSDimitry Andric 2630b57cec5SDimitry Andricclass MTBUF_Store_Pseudo <string opName, 2640b57cec5SDimitry Andric int addrKind, 2650b57cec5SDimitry Andric RegisterClass vdataClass, 2668bcb0991SDimitry Andric int elems, 267*0fca6ea1SDimitry Andric bit hasRestrictedSOffset = 0, 2680b57cec5SDimitry Andric list<dag> pattern=[], 2690b57cec5SDimitry Andric // Workaround bug bz30254 2700b57cec5SDimitry Andric int addrKindCopy = addrKind, 2710b57cec5SDimitry Andric RegisterClass vdataClassCopy = vdataClass> 2720b57cec5SDimitry Andric : MTBUF_Pseudo<opName, 2730b57cec5SDimitry Andric (outs), 274*0fca6ea1SDimitry Andric getMTBUFIns<addrKindCopy, [vdataClassCopy], hasRestrictedSOffset>.ret, 275bdd1243dSDimitry Andric getMTBUFAsmOps<addrKindCopy>.ret, 2760b57cec5SDimitry Andric pattern>, 2770b57cec5SDimitry Andric MTBUF_SetupAddr<addrKindCopy> { 2780b57cec5SDimitry Andric let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret; 2790b57cec5SDimitry Andric let mayLoad = 0; 2800b57cec5SDimitry Andric let mayStore = 1; 2818bcb0991SDimitry Andric let elements = elems; 2820b57cec5SDimitry Andric} 2830b57cec5SDimitry Andric 2845f757f3fSDimitry Andricmulticlass MTBUF_Pseudo_Stores_Helper<string opName, RegisterClass vdataClass, 285*0fca6ea1SDimitry Andric int elems, bit hasRestrictedSOffset> { 2860b57cec5SDimitry Andric 287*0fca6ea1SDimitry Andric def _OFFSET : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems, hasRestrictedSOffset>, 2880b57cec5SDimitry Andric MTBUFAddr64Table<0, NAME>; 2890b57cec5SDimitry Andric 290*0fca6ea1SDimitry Andric def _ADDR64 : MTBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, elems, hasRestrictedSOffset>, 2910b57cec5SDimitry Andric MTBUFAddr64Table<1, NAME>; 2920b57cec5SDimitry Andric 293*0fca6ea1SDimitry Andric def _OFFEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems, hasRestrictedSOffset>; 294*0fca6ea1SDimitry Andric def _IDXEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems, hasRestrictedSOffset>; 295*0fca6ea1SDimitry Andric def _BOTHEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems, hasRestrictedSOffset>; 2960b57cec5SDimitry Andric 2970b57cec5SDimitry Andric let DisableWQM = 1 in { 298*0fca6ea1SDimitry Andric def _OFFSET_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems, hasRestrictedSOffset>; 299*0fca6ea1SDimitry Andric def _OFFEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems, hasRestrictedSOffset>; 300*0fca6ea1SDimitry Andric def _IDXEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems, hasRestrictedSOffset>; 301*0fca6ea1SDimitry Andric def _BOTHEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems, hasRestrictedSOffset>; 3020b57cec5SDimitry Andric } 3030b57cec5SDimitry Andric} 3040b57cec5SDimitry Andric 3055f757f3fSDimitry Andricmulticlass MTBUF_Pseudo_Stores<string opName, RegisterClass vdataClass, 3065f757f3fSDimitry Andric int elems> { 3075f757f3fSDimitry Andric defm NAME : MTBUF_Pseudo_Stores_Helper<opName, vdataClass, elems, 0>; 3085f757f3fSDimitry Andric defm _VBUFFER : MTBUF_Pseudo_Stores_Helper<opName, vdataClass, elems, 1>; 3095f757f3fSDimitry Andric} 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 3120b57cec5SDimitry Andric// MUBUF classes 3130b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 3140b57cec5SDimitry Andric 3150b57cec5SDimitry Andricclass MUBUFGetBaseOpcode<string Op> { 3160b57cec5SDimitry Andric string ret = !subst("DWORDX2", "DWORD", 3170b57cec5SDimitry Andric !subst("DWORDX3", "DWORD", 3180b57cec5SDimitry Andric !subst("DWORDX4", "DWORD", Op))); 3190b57cec5SDimitry Andric} 3200b57cec5SDimitry Andric 3210b57cec5SDimitry Andricclass MUBUF_Pseudo <string opName, dag outs, dag ins, 3220b57cec5SDimitry Andric string asmOps, list<dag> pattern=[]> : 323bdd1243dSDimitry Andric BUF_Pseudo <opName, outs, ins, asmOps, pattern> { 3240b57cec5SDimitry Andric 3250b57cec5SDimitry Andric Instruction BaseOpcode = !cast<Instruction>(MUBUFGetBaseOpcode<NAME>.ret); 3260b57cec5SDimitry Andric let MUBUF = 1; 3270b57cec5SDimitry Andric let AsmMatchConverter = "cvtMubuf"; 328*0fca6ea1SDimitry Andric let usesCustomInserter = 1; 3290b57cec5SDimitry Andric} 3300b57cec5SDimitry Andric 33181ad6265SDimitry Andricclass MUBUF_Real <MUBUF_Pseudo ps, string real_name = ps.Mnemonic> : 33281ad6265SDimitry Andric InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []> { 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andric let isPseudo = 0; 3350b57cec5SDimitry Andric let isCodeGenOnly = 0; 3360b57cec5SDimitry Andric 337fe6060f1SDimitry Andric let VM_CNT = 1; 338fe6060f1SDimitry Andric let EXP_CNT = 1; 339fe6060f1SDimitry Andric let MUBUF = 1; 340fe6060f1SDimitry Andric 3410b57cec5SDimitry Andric // copy relevant pseudo op flags 3420b57cec5SDimitry Andric let SubtargetPredicate = ps.SubtargetPredicate; 3430b57cec5SDimitry Andric let AsmMatchConverter = ps.AsmMatchConverter; 344e8d8bef9SDimitry Andric let OtherPredicates = ps.OtherPredicates; 3450b57cec5SDimitry Andric let Constraints = ps.Constraints; 3460b57cec5SDimitry Andric let DisableEncoding = ps.DisableEncoding; 3470b57cec5SDimitry Andric let TSFlags = ps.TSFlags; 348e8d8bef9SDimitry Andric let UseNamedOperandTable = ps.UseNamedOperandTable; 349fe6060f1SDimitry Andric let SchedRW = ps.SchedRW; 350fe6060f1SDimitry Andric let mayLoad = ps.mayLoad; 351fe6060f1SDimitry Andric let mayStore = ps.mayStore; 352fe6060f1SDimitry Andric let IsAtomicRet = ps.IsAtomicRet; 353fe6060f1SDimitry Andric let IsAtomicNoRet = ps.IsAtomicNoRet; 35481ad6265SDimitry Andric let VALU = ps.VALU; 35581ad6265SDimitry Andric let LGKM_CNT = ps.LGKM_CNT; 356*0fca6ea1SDimitry Andric let Uses = ps.Uses; 357*0fca6ea1SDimitry Andric let Defs = ps.Defs; 3580b57cec5SDimitry Andric 3590b57cec5SDimitry Andric bits<12> offset; 360fe6060f1SDimitry Andric bits<5> cpol; 3610b57cec5SDimitry Andric bits<8> vaddr; 362fe6060f1SDimitry Andric bits<10> vdata; 3630b57cec5SDimitry Andric bits<7> srsrc; 3640b57cec5SDimitry Andric bits<8> soffset; 365fe6060f1SDimitry Andric 366fe6060f1SDimitry Andric // GFX90A+ only: instruction uses AccVGPR for data 36781ad6265SDimitry Andric // Bit supersedes tfe. 368bdd1243dSDimitry Andric bits<1> acc = !if(ps.has_vdata, vdata{9}, 0); 3690b57cec5SDimitry Andric} 3700b57cec5SDimitry Andric 3710b57cec5SDimitry Andric// For cache invalidation instructions. 3720b57cec5SDimitry Andricclass MUBUF_Invalidate <string opName, SDPatternOperator node = null_frag> : 3730b57cec5SDimitry Andric MUBUF_Pseudo<opName, (outs), (ins), "", [(node)]> { 3740b57cec5SDimitry Andric 3750b57cec5SDimitry Andric let AsmMatchConverter = ""; 3760b57cec5SDimitry Andric 3770b57cec5SDimitry Andric let hasSideEffects = 1; 3785ffd83dbSDimitry Andric let mayLoad = 0; 3795ffd83dbSDimitry Andric let mayStore = 0; 3800b57cec5SDimitry Andric 381fe6060f1SDimitry Andric let IsBufferInv = 1; 382fe6060f1SDimitry Andric // Set everything else to 0. 3830b57cec5SDimitry Andric let offen = 0; 3840b57cec5SDimitry Andric let idxen = 0; 3850b57cec5SDimitry Andric let addr64 = 0; 3860b57cec5SDimitry Andric let has_vdata = 0; 3870b57cec5SDimitry Andric let has_vaddr = 0; 3880b57cec5SDimitry Andric let has_glc = 0; 3890b57cec5SDimitry Andric let has_dlc = 0; 3900b57cec5SDimitry Andric let glc_value = 0; 3910b57cec5SDimitry Andric let dlc_value = 0; 3920b57cec5SDimitry Andric let has_srsrc = 0; 3930b57cec5SDimitry Andric let has_soffset = 0; 3940b57cec5SDimitry Andric let has_offset = 0; 3950b57cec5SDimitry Andric let has_slc = 0; 396fe6060f1SDimitry Andric let has_sccb = 0; 397fe6060f1SDimitry Andric let sccb_value = 0; 3980b57cec5SDimitry Andric} 3990b57cec5SDimitry Andric 400bdd1243dSDimitry Andricclass getLdStVDataRegisterOperand<RegisterClass RC, bit isTFE> { 401bdd1243dSDimitry Andric RegisterOperand tfeVDataOp = 402*0fca6ea1SDimitry Andric !cond(!eq(RC.Size, 32) : AVLdSt_64, 403*0fca6ea1SDimitry Andric !eq(RC.Size, 64) : AVLdSt_96, 404*0fca6ea1SDimitry Andric !eq(RC.Size, 96) : AVLdSt_128, 405*0fca6ea1SDimitry Andric !eq(RC.Size, 128) : AVLdSt_160); 406bdd1243dSDimitry Andric 407bdd1243dSDimitry Andric RegisterOperand ret = !if(isTFE, tfeVDataOp, getLdStRegisterOperand<RC>.ret); 408bdd1243dSDimitry Andric} 409bdd1243dSDimitry Andric 4100b57cec5SDimitry Andricclass getMUBUFInsDA<list<RegisterClass> vdataList, 411*0fca6ea1SDimitry Andric list<RegisterClass> vaddrList, bit isTFE, bit hasRestrictedSOffset> { 4120b57cec5SDimitry Andric RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList)); 4130b57cec5SDimitry Andric RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList)); 414bdd1243dSDimitry Andric RegisterOperand vdata_op = getLdStVDataRegisterOperand<vdataClass, isTFE>.ret; 415bdd1243dSDimitry Andric 416*0fca6ea1SDimitry Andric dag SOffset = !if(hasRestrictedSOffset, (ins SReg_32:$soffset), (ins SCSrc_b32:$soffset)); 417*0fca6ea1SDimitry Andric dag NonVaddrInputs = !con((ins SReg_128:$srsrc), SOffset, (ins Offset:$offset, CPol_0:$cpol, i1imm_0:$swz)); 4185f757f3fSDimitry Andric 419bdd1243dSDimitry Andric dag Inputs = !if(!empty(vaddrList), NonVaddrInputs, !con((ins vaddrClass:$vaddr), NonVaddrInputs)); 420bdd1243dSDimitry Andric dag ret = !if(!empty(vdataList), Inputs, !con((ins vdata_op:$vdata), Inputs)); 4210b57cec5SDimitry Andric} 4220b57cec5SDimitry Andric 4238bcb0991SDimitry Andricclass getMUBUFElements<ValueType vt> { 4240b57cec5SDimitry Andric int ret = 425fe6060f1SDimitry Andric !if(!eq(vt, f16), 1, 426fe6060f1SDimitry Andric !if(!eq(vt, v2f16), 2, 427fe6060f1SDimitry Andric !if(!eq(vt, v3f16), 3, 428fe6060f1SDimitry Andric !if(!eq(vt, v4f16), 4, 4298bcb0991SDimitry Andric !if(!eq(vt.Size, 32), 1, 4308bcb0991SDimitry Andric !if(!eq(vt.Size, 64), 2, 4318bcb0991SDimitry Andric !if(!eq(vt.Size, 96), 3, 4328bcb0991SDimitry Andric !if(!eq(vt.Size, 128), 4, 0) 4338bcb0991SDimitry Andric ) 4348bcb0991SDimitry Andric ) 4358bcb0991SDimitry Andric ) 4368bcb0991SDimitry Andric ) 4378bcb0991SDimitry Andric ) 4388bcb0991SDimitry Andric ) 4398bcb0991SDimitry Andric ); 4400b57cec5SDimitry Andric} 4410b57cec5SDimitry Andric 442*0fca6ea1SDimitry Andricclass getMUBUFIns<int addrKind, list<RegisterClass> vdataList, bit isTFE, bit hasRestrictedSOffset> { 4430b57cec5SDimitry Andric dag ret = 444*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Offset), getMUBUFInsDA<vdataList, [], isTFE, hasRestrictedSOffset>.ret, 445*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.OffEn), getMUBUFInsDA<vdataList, [VGPR_32], isTFE, hasRestrictedSOffset>.ret, 446*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.IdxEn), getMUBUFInsDA<vdataList, [VGPR_32], isTFE, hasRestrictedSOffset>.ret, 447*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.BothEn), getMUBUFInsDA<vdataList, [VReg_64], isTFE, hasRestrictedSOffset>.ret, 448*0fca6ea1SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Addr64), getMUBUFInsDA<vdataList, [VReg_64], isTFE, hasRestrictedSOffset>.ret, 4490b57cec5SDimitry Andric (ins)))))); 4500b57cec5SDimitry Andric} 4510b57cec5SDimitry Andric 45206c3fb27SDimitry Andricclass getMUBUFAsmOps<int addrKind, bit noVdata = 0, bit isLds = 0, bit isTFE = 0> { 453bdd1243dSDimitry Andric string Vdata = !if(noVdata, " ", " $vdata, "); 454bdd1243dSDimitry Andric string Lds = !if(isLds, " lds", ""); 455bdd1243dSDimitry Andric string TFE = !if(isTFE, " tfe", ""); 456bdd1243dSDimitry Andric string MainArgs = 4570b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc, $soffset", 4580b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.OffEn), "$vaddr, $srsrc, $soffset offen", 4590b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.IdxEn), "$vaddr, $srsrc, $soffset idxen", 4600b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.BothEn), "$vaddr, $srsrc, $soffset idxen offen", 4610b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Addr64), "$vaddr, $srsrc, $soffset addr64", 4620b57cec5SDimitry Andric ""))))); 463bdd1243dSDimitry Andric string Offset = "$offset"; 464bdd1243dSDimitry Andric string OtherArgs = "$cpol"; 465bdd1243dSDimitry Andric 46606c3fb27SDimitry Andric string ret = Vdata # MainArgs # Offset # OtherArgs # Lds # TFE; 4670b57cec5SDimitry Andric} 4680b57cec5SDimitry Andric 4690b57cec5SDimitry Andricclass MUBUF_SetupAddr<int addrKind> { 470e8d8bef9SDimitry Andric bits<1> offen = !or(!eq(addrKind, BUFAddrKind.OffEn), 471e8d8bef9SDimitry Andric !eq(addrKind, BUFAddrKind.BothEn)); 4720b57cec5SDimitry Andric 473e8d8bef9SDimitry Andric bits<1> idxen = !or(!eq(addrKind, BUFAddrKind.IdxEn), 474e8d8bef9SDimitry Andric !eq(addrKind, BUFAddrKind.BothEn)); 4750b57cec5SDimitry Andric 476e8d8bef9SDimitry Andric bits<1> addr64 = !eq(addrKind, BUFAddrKind.Addr64); 4770b57cec5SDimitry Andric 478e8d8bef9SDimitry Andric bits<1> has_vaddr = !ne(addrKind, BUFAddrKind.Offset); 4790b57cec5SDimitry Andric} 4800b57cec5SDimitry Andric 4810b57cec5SDimitry Andricclass MUBUF_Load_Pseudo <string opName, 4820b57cec5SDimitry Andric int addrKind, 4838bcb0991SDimitry Andric ValueType vdata_vt, 4840b57cec5SDimitry Andric bit HasTiedDest = 0, 4850b57cec5SDimitry Andric bit isLds = 0, 48681ad6265SDimitry Andric bit isLdsOpc = 0, 487bdd1243dSDimitry Andric bit isTFE = 0, 488*0fca6ea1SDimitry Andric bit hasRestrictedSOffset = 0, 4890b57cec5SDimitry Andric list<dag> pattern=[], 4900b57cec5SDimitry Andric // Workaround bug bz30254 491fe6060f1SDimitry Andric int addrKindCopy = addrKind, 4927a6dacacSDimitry Andric RegisterClass vdata_rc = getVregSrcForVT<vdata_vt>.ret.RegClass, 493bdd1243dSDimitry Andric RegisterOperand vdata_op = getLdStVDataRegisterOperand<vdata_rc, isTFE>.ret> 4940b57cec5SDimitry Andric : MUBUF_Pseudo<opName, 49581ad6265SDimitry Andric !if(!or(isLds, isLdsOpc), (outs), (outs vdata_op:$vdata)), 496*0fca6ea1SDimitry Andric !con(getMUBUFIns<addrKindCopy, [], isTFE, hasRestrictedSOffset>.ret, 497fe6060f1SDimitry Andric !if(HasTiedDest, (ins vdata_op:$vdata_in), (ins))), 49806c3fb27SDimitry Andric getMUBUFAsmOps<addrKindCopy, !or(isLds, isLdsOpc), isLds, isTFE>.ret, 4990b57cec5SDimitry Andric pattern>, 5000b57cec5SDimitry Andric MUBUF_SetupAddr<addrKindCopy> { 501bdd1243dSDimitry Andric let PseudoInstr = opName # !if(isLds, "_lds", "") # !if(isTFE, "_tfe", "") # 5020b57cec5SDimitry Andric "_" # getAddrName<addrKindCopy>.ret; 503bdd1243dSDimitry Andric let AsmMatchConverter = "cvtMubuf"; 5040b57cec5SDimitry Andric 5050b57cec5SDimitry Andric let Constraints = !if(HasTiedDest, "$vdata = $vdata_in", ""); 50681ad6265SDimitry Andric let LGKM_CNT = isLds; 507bdd1243dSDimitry Andric let has_vdata = !not(!or(isLds, isLdsOpc)); 5080b57cec5SDimitry Andric let mayLoad = 1; 50981ad6265SDimitry Andric let mayStore = isLds; 51081ad6265SDimitry Andric let Uses = !if(!or(isLds, isLdsOpc) , [EXEC, M0], [EXEC]); 511bdd1243dSDimitry Andric let tfe = isTFE; 5120b57cec5SDimitry Andric let lds = isLds; 5138bcb0991SDimitry Andric let elements = getMUBUFElements<vdata_vt>.ret; 51481ad6265SDimitry Andric let VALU = isLds; 5150b57cec5SDimitry Andric} 5160b57cec5SDimitry Andric 5175f757f3fSDimitry Andricclass MUBUF_Offset_Load_Pat <Instruction inst, ValueType load_vt = i32, SDPatternOperator ld = null_frag> : GCNPat < 51806c3fb27SDimitry Andric (load_vt (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset))), 51906c3fb27SDimitry Andric (load_vt (inst v4i32:$srsrc, i32:$soffset, i32:$offset)) 5200b57cec5SDimitry Andric>; 5210b57cec5SDimitry Andric 5220b57cec5SDimitry Andricclass MUBUF_Addr64_Load_Pat <Instruction inst, 5230b57cec5SDimitry Andric ValueType load_vt = i32, 5245f757f3fSDimitry Andric SDPatternOperator ld = null_frag> : GCNPat < 52506c3fb27SDimitry Andric (load_vt (ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset))), 52606c3fb27SDimitry Andric (load_vt (inst i64:$vaddr, v4i32:$srsrc, i32:$soffset, i32:$offset)) 5270b57cec5SDimitry Andric>; 5280b57cec5SDimitry Andric 5295f757f3fSDimitry Andricmulticlass MUBUF_Pseudo_Load_Pats_Common<string BaseInst, ValueType load_vt = i32, SDPatternOperator ld = null_frag> { 5300b57cec5SDimitry Andric def : MUBUF_Offset_Load_Pat<!cast<Instruction>(BaseInst#"_OFFSET"), load_vt, ld>; 5310b57cec5SDimitry Andric def : MUBUF_Addr64_Load_Pat<!cast<Instruction>(BaseInst#"_ADDR64"), load_vt, ld>; 5320b57cec5SDimitry Andric} 5330b57cec5SDimitry Andric 5345f757f3fSDimitry Andricmulticlass MUBUF_Pseudo_Load_Pats<string BaseInst, ValueType load_vt = i32, SDPatternOperator ld = null_frag>{ 535*0fca6ea1SDimitry Andric let OtherPredicates = [HasUnrestrictedSOffset] in { 5365f757f3fSDimitry Andric defm : MUBUF_Pseudo_Load_Pats_Common<BaseInst, load_vt, ld>; 5375f757f3fSDimitry Andric } 5385f757f3fSDimitry Andric defm : MUBUF_Pseudo_Load_Pats_Common<BaseInst # "_VBUFFER", load_vt, ld>; 5395f757f3fSDimitry Andric} 5405f757f3fSDimitry Andric 541bdd1243dSDimitry Andricmulticlass MUBUF_Pseudo_Loads_Helper<string opName, ValueType load_vt, 542*0fca6ea1SDimitry Andric bit TiedDest, bit isLds, bit isTFE, bit hasRestrictedSOffset> { 543fe6060f1SDimitry Andric defvar legal_load_vt = !if(!eq(load_vt, v3f16), v4f16, load_vt); 544e8d8bef9SDimitry Andric 545*0fca6ea1SDimitry Andric def _OFFSET : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>, 5460b57cec5SDimitry Andric MUBUFAddr64Table<0, NAME # !if(isLds, "_LDS", "")>; 5470b57cec5SDimitry Andric 548*0fca6ea1SDimitry Andric def _ADDR64 : MUBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>, 5490b57cec5SDimitry Andric MUBUFAddr64Table<1, NAME # !if(isLds, "_LDS", "")>; 5500b57cec5SDimitry Andric 551*0fca6ea1SDimitry Andric def _OFFEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>; 552*0fca6ea1SDimitry Andric def _IDXEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>; 553*0fca6ea1SDimitry Andric def _BOTHEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>; 5540b57cec5SDimitry Andric 5550b57cec5SDimitry Andric let DisableWQM = 1 in { 556*0fca6ea1SDimitry Andric def _OFFSET_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>; 557*0fca6ea1SDimitry Andric def _OFFEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>; 558*0fca6ea1SDimitry Andric def _IDXEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>; 559*0fca6ea1SDimitry Andric def _BOTHEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, legal_load_vt, TiedDest, isLds, 0, isTFE, hasRestrictedSOffset>; 5600b57cec5SDimitry Andric } 5610b57cec5SDimitry Andric} 5620b57cec5SDimitry Andric 563bdd1243dSDimitry Andricmulticlass MUBUF_Pseudo_Loads<string opName, ValueType load_vt = i32, 564bdd1243dSDimitry Andric bit TiedDest = 0, bit isLds = 0> { 5655f757f3fSDimitry Andric defm NAME : MUBUF_Pseudo_Loads_Helper<opName, load_vt, TiedDest, isLds, 0, 0>; 5665f757f3fSDimitry Andric defm _VBUFFER : MUBUF_Pseudo_Loads_Helper<opName, load_vt, TiedDest, isLds, 0, 1>; 5675f757f3fSDimitry Andric 5685f757f3fSDimitry Andric if !not(isLds) then { 5695f757f3fSDimitry Andric defm _TFE : MUBUF_Pseudo_Loads_Helper<opName, load_vt, TiedDest, isLds, 1, 0>; 5705f757f3fSDimitry Andric defm _TFE_VBUFFER : MUBUF_Pseudo_Loads_Helper<opName, load_vt, TiedDest, isLds, 1, 1>; 5715f757f3fSDimitry Andric } 572bdd1243dSDimitry Andric} 573bdd1243dSDimitry Andric 574349cc55cSDimitry Andricmulticlass MUBUF_Pseudo_Loads_Lds<string opName, ValueType load_vt = i32> { 575349cc55cSDimitry Andric defm NAME : MUBUF_Pseudo_Loads<opName, load_vt>; 576349cc55cSDimitry Andric defm _LDS : MUBUF_Pseudo_Loads<opName, load_vt, 0, 1>; 5770b57cec5SDimitry Andric} 5780b57cec5SDimitry Andric 57981ad6265SDimitry Andricmulticlass MUBUF_Pseudo_Loads_LDSOpc<string opName, 58081ad6265SDimitry Andric ValueType load_vt = i32, 58181ad6265SDimitry Andric bit TiedDest = 0, 58281ad6265SDimitry Andric bit isLds = 0, 58381ad6265SDimitry Andric bit isLdsOpc = 1> { 58481ad6265SDimitry Andric 58581ad6265SDimitry Andric defvar legal_load_vt = !if(!eq(!cast<string>(load_vt), !cast<string>(v3f16)), v4f16, load_vt); 58681ad6265SDimitry Andric 58781ad6265SDimitry Andric def _OFFSET : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, legal_load_vt, TiedDest, isLds, isLdsOpc>; 58881ad6265SDimitry Andric def _OFFEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, legal_load_vt, TiedDest, isLds, isLdsOpc>; 58981ad6265SDimitry Andric def _IDXEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, legal_load_vt, TiedDest, isLds, isLdsOpc>; 59081ad6265SDimitry Andric def _BOTHEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, legal_load_vt, TiedDest, isLds, isLdsOpc>; 5915f757f3fSDimitry Andric 5925f757f3fSDimitry Andric def _VBUFFER_OFFSET : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, legal_load_vt, TiedDest, isLds, isLdsOpc, 0, 1>; 5935f757f3fSDimitry Andric def _VBUFFER_OFFEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, legal_load_vt, TiedDest, isLds, isLdsOpc, 0, 1>; 5945f757f3fSDimitry Andric def _VBUFFER_IDXEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, legal_load_vt, TiedDest, isLds, isLdsOpc, 0, 1>; 5955f757f3fSDimitry Andric def _VBUFFER_BOTHEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, legal_load_vt, TiedDest, isLds, isLdsOpc, 0, 1>; 59681ad6265SDimitry Andric} 59781ad6265SDimitry Andric 5980b57cec5SDimitry Andricclass MUBUF_Store_Pseudo <string opName, 5990b57cec5SDimitry Andric int addrKind, 6008bcb0991SDimitry Andric ValueType store_vt, 601bdd1243dSDimitry Andric bit isTFE = 0, 602*0fca6ea1SDimitry Andric bit hasRestrictedSOffset = 0, 6030b57cec5SDimitry Andric list<dag> pattern=[], 6040b57cec5SDimitry Andric // Workaround bug bz30254 6058bcb0991SDimitry Andric int addrKindCopy = addrKind> 6060b57cec5SDimitry Andric : MUBUF_Pseudo<opName, 6070b57cec5SDimitry Andric (outs), 608*0fca6ea1SDimitry Andric getMUBUFIns<addrKindCopy, [getVregSrcForVT<store_vt>.ret.RegClass], isTFE, hasRestrictedSOffset>.ret, 60906c3fb27SDimitry Andric getMUBUFAsmOps<addrKindCopy, 0, 0, isTFE>.ret, 6100b57cec5SDimitry Andric pattern>, 6110b57cec5SDimitry Andric MUBUF_SetupAddr<addrKindCopy> { 612bdd1243dSDimitry Andric let PseudoInstr = opName # "_" # !if(isTFE, "_tfe", "") # 613bdd1243dSDimitry Andric getAddrName<addrKindCopy>.ret; 6140b57cec5SDimitry Andric let mayLoad = 0; 6150b57cec5SDimitry Andric let mayStore = 1; 6168bcb0991SDimitry Andric let elements = getMUBUFElements<store_vt>.ret; 617bdd1243dSDimitry Andric let tfe = isTFE; 6180b57cec5SDimitry Andric} 6190b57cec5SDimitry Andric 6205f757f3fSDimitry Andricmulticlass MUBUF_Pseudo_Store_Pats_Common<string BaseInst, ValueType store_vt = i32, SDPatternOperator st = null_frag> { 6215f757f3fSDimitry Andric 6225f757f3fSDimitry Andric def : GCNPat < 6235f757f3fSDimitry Andric (st store_vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset)), 6245f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(BaseInst # _OFFSET) store_vt:$vdata, v4i32:$srsrc, i32:$soffset, i32:$offset)>; 6255f757f3fSDimitry Andric 6265f757f3fSDimitry Andric def : GCNPat < 6275f757f3fSDimitry Andric (st store_vt:$vdata, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset)), 6285f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(BaseInst # _ADDR64) store_vt:$vdata, i64:$vaddr, v4i32:$srsrc, i32:$soffset, i32:$offset)>; 6295f757f3fSDimitry Andric} 6305f757f3fSDimitry Andric 6315f757f3fSDimitry Andricmulticlass MUBUF_Pseudo_Store_Pats<string BaseInst, ValueType store_vt = i32, SDPatternOperator st = null_frag> { 632*0fca6ea1SDimitry Andric let OtherPredicates = [HasUnrestrictedSOffset] in { 6335f757f3fSDimitry Andric defm : MUBUF_Pseudo_Store_Pats_Common<BaseInst, store_vt, st>; 6345f757f3fSDimitry Andric } 6355f757f3fSDimitry Andric defm : MUBUF_Pseudo_Store_Pats_Common<BaseInst # "_VBUFFER", store_vt, st>; 6365f757f3fSDimitry Andric} 6375f757f3fSDimitry Andric 638bdd1243dSDimitry Andricmulticlass MUBUF_Pseudo_Stores_Helper<string opName, ValueType store_vt, 639*0fca6ea1SDimitry Andric bit isTFE, bit hasRestrictedSOffset> { 640fe6060f1SDimitry Andric defvar legal_store_vt = !if(!eq(store_vt, v3f16), v4f16, store_vt); 641e8d8bef9SDimitry Andric 642*0fca6ea1SDimitry Andric def _OFFSET : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, legal_store_vt, isTFE, hasRestrictedSOffset>, 6430b57cec5SDimitry Andric MUBUFAddr64Table<0, NAME>; 6440b57cec5SDimitry Andric 645*0fca6ea1SDimitry Andric def _ADDR64 : MUBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, legal_store_vt, isTFE, hasRestrictedSOffset>, 6460b57cec5SDimitry Andric MUBUFAddr64Table<1, NAME>; 6470b57cec5SDimitry Andric 648*0fca6ea1SDimitry Andric def _OFFEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, legal_store_vt, isTFE, hasRestrictedSOffset>; 649*0fca6ea1SDimitry Andric def _IDXEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, legal_store_vt, isTFE, hasRestrictedSOffset>; 650*0fca6ea1SDimitry Andric def _BOTHEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, legal_store_vt, isTFE, hasRestrictedSOffset>; 6510b57cec5SDimitry Andric 6520b57cec5SDimitry Andric let DisableWQM = 1 in { 653*0fca6ea1SDimitry Andric def _OFFSET_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, legal_store_vt, isTFE, hasRestrictedSOffset>; 654*0fca6ea1SDimitry Andric def _OFFEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, legal_store_vt, isTFE, hasRestrictedSOffset>; 655*0fca6ea1SDimitry Andric def _IDXEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, legal_store_vt, isTFE, hasRestrictedSOffset>; 656*0fca6ea1SDimitry Andric def _BOTHEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, legal_store_vt, isTFE, hasRestrictedSOffset>; 6570b57cec5SDimitry Andric } 6580b57cec5SDimitry Andric} 6590b57cec5SDimitry Andric 6605f757f3fSDimitry Andricmulticlass MUBUF_Pseudo_Stores<string opName, ValueType store_vt = i32> { 6615f757f3fSDimitry Andric defm NAME : MUBUF_Pseudo_Stores_Helper<opName, store_vt, 0, 0>; 6625f757f3fSDimitry Andric defm _TFE : MUBUF_Pseudo_Stores_Helper<opName, store_vt, 1, 0>; 6635f757f3fSDimitry Andric 6645f757f3fSDimitry Andric defm _VBUFFER : MUBUF_Pseudo_Stores_Helper<opName, store_vt, 0, 1>; 6655f757f3fSDimitry Andric defm _TFE_VBUFFER : MUBUF_Pseudo_Stores_Helper<opName, store_vt, 1, 1>; 666bdd1243dSDimitry Andric} 667bdd1243dSDimitry Andric 6680b57cec5SDimitry Andricclass MUBUF_Pseudo_Store_Lds<string opName> 6690b57cec5SDimitry Andric : MUBUF_Pseudo<opName, 6700b57cec5SDimitry Andric (outs), 671*0fca6ea1SDimitry Andric (ins SReg_128:$srsrc, SCSrc_b32:$soffset, Offset:$offset, CPol:$cpol, i1imm:$swz), 67206c3fb27SDimitry Andric " $srsrc, $soffset$offset lds$cpol"> { 67381ad6265SDimitry Andric let LGKM_CNT = 1; 67481ad6265SDimitry Andric let mayLoad = 1; 6750b57cec5SDimitry Andric let mayStore = 1; 6760b57cec5SDimitry Andric 6770b57cec5SDimitry Andric let has_vdata = 0; 6780b57cec5SDimitry Andric let has_vaddr = 0; 6790b57cec5SDimitry Andric let lds = 1; 68081ad6265SDimitry Andric let VALU = 1; 6810b57cec5SDimitry Andric 6820b57cec5SDimitry Andric let Uses = [EXEC, M0]; 683bdd1243dSDimitry Andric let AsmMatchConverter = "cvtMubuf"; 6840b57cec5SDimitry Andric} 6850b57cec5SDimitry Andric 686*0fca6ea1SDimitry Andricclass getMUBUFAtomicInsDA<RegisterClass vdataClass, bit vdata_in, bit hasRestrictedSOffset, 6870b57cec5SDimitry Andric list<RegisterClass> vaddrList=[]> { 6880b57cec5SDimitry Andric RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList)); 689fe6060f1SDimitry Andric RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret; 690bdd1243dSDimitry Andric 691bdd1243dSDimitry Andric dag VData = !if(vdata_in, (ins vdata_op:$vdata_in), (ins vdata_op:$vdata)); 692bdd1243dSDimitry Andric dag Data = !if(!empty(vaddrList), VData, !con(VData, (ins vaddrClass:$vaddr))); 693*0fca6ea1SDimitry Andric dag SOffset = !if(hasRestrictedSOffset, (ins SReg_32:$soffset), (ins SCSrc_b32:$soffset)); 694*0fca6ea1SDimitry Andric dag MainInputs = !con((ins SReg_128:$srsrc), SOffset, (ins Offset:$offset)); 6955f757f3fSDimitry Andric dag CPol = !if(vdata_in, (ins CPol_GLC_WithDefault:$cpol), 6965f757f3fSDimitry Andric (ins CPol_NonGLC_WithDefault:$cpol)); 697bdd1243dSDimitry Andric 69806c3fb27SDimitry Andric dag ret = !con(Data, MainInputs, CPol); 6990b57cec5SDimitry Andric} 7000b57cec5SDimitry Andric 7010b57cec5SDimitry Andricclass getMUBUFAtomicIns<int addrKind, 7020b57cec5SDimitry Andric RegisterClass vdataClass, 7030b57cec5SDimitry Andric bit vdata_in, 704*0fca6ea1SDimitry Andric bit hasRestrictedSOffset, 7050b57cec5SDimitry Andric // Workaround bug bz30254 7060b57cec5SDimitry Andric RegisterClass vdataClassCopy=vdataClass> { 7070b57cec5SDimitry Andric dag ret = 7080b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Offset), 709*0fca6ea1SDimitry Andric getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, hasRestrictedSOffset>.ret, 7100b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.OffEn), 711*0fca6ea1SDimitry Andric getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, hasRestrictedSOffset, [VGPR_32]>.ret, 7120b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.IdxEn), 713*0fca6ea1SDimitry Andric getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, hasRestrictedSOffset, [VGPR_32]>.ret, 7140b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.BothEn), 715*0fca6ea1SDimitry Andric getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, hasRestrictedSOffset, [VReg_64]>.ret, 7160b57cec5SDimitry Andric !if(!eq(addrKind, BUFAddrKind.Addr64), 717*0fca6ea1SDimitry Andric getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, hasRestrictedSOffset, [VReg_64]>.ret, 7180b57cec5SDimitry Andric (ins)))))); 7190b57cec5SDimitry Andric} 7200b57cec5SDimitry Andric 7210b57cec5SDimitry Andricclass MUBUF_Atomic_Pseudo<string opName, 7220b57cec5SDimitry Andric int addrKind, 7230b57cec5SDimitry Andric dag outs, 7240b57cec5SDimitry Andric dag ins, 7250b57cec5SDimitry Andric string asmOps, 7260b57cec5SDimitry Andric list<dag> pattern=[], 7270b57cec5SDimitry Andric // Workaround bug bz30254 7280b57cec5SDimitry Andric int addrKindCopy = addrKind> 7290b57cec5SDimitry Andric : MUBUF_Pseudo<opName, outs, ins, asmOps, pattern>, 7300b57cec5SDimitry Andric MUBUF_SetupAddr<addrKindCopy> { 7310b57cec5SDimitry Andric let mayStore = 1; 7320b57cec5SDimitry Andric let mayLoad = 1; 7330b57cec5SDimitry Andric let hasPostISelHook = 1; 7340b57cec5SDimitry Andric let hasSideEffects = 1; 7350b57cec5SDimitry Andric let DisableWQM = 1; 7360b57cec5SDimitry Andric let has_glc = 0; 7370b57cec5SDimitry Andric let has_dlc = 0; 738fe6060f1SDimitry Andric let has_sccb = 1; 739fe6060f1SDimitry Andric let AsmMatchConverter = "cvtMubufAtomic"; 7400b57cec5SDimitry Andric} 7410b57cec5SDimitry Andric 7420b57cec5SDimitry Andricclass MUBUF_AtomicNoRet_Pseudo<string opName, int addrKind, 7430b57cec5SDimitry Andric RegisterClass vdataClass, 744*0fca6ea1SDimitry Andric bit hasRestrictedSOffset = 0, 7450b57cec5SDimitry Andric list<dag> pattern=[], 7460b57cec5SDimitry Andric // Workaround bug bz30254 7470b57cec5SDimitry Andric int addrKindCopy = addrKind, 7480b57cec5SDimitry Andric RegisterClass vdataClassCopy = vdataClass> 7490b57cec5SDimitry Andric : MUBUF_Atomic_Pseudo<opName, addrKindCopy, 7500b57cec5SDimitry Andric (outs), 751*0fca6ea1SDimitry Andric getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 0, hasRestrictedSOffset>.ret, 752bdd1243dSDimitry Andric getMUBUFAsmOps<addrKindCopy>.ret, 753*0fca6ea1SDimitry Andric pattern> { 7540b57cec5SDimitry Andric let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret; 7550b57cec5SDimitry Andric let glc_value = 0; 7560b57cec5SDimitry Andric let dlc_value = 0; 757fe6060f1SDimitry Andric let sccb_value = 0; 758fe6060f1SDimitry Andric let IsAtomicNoRet = 1; 7590b57cec5SDimitry Andric} 7600b57cec5SDimitry Andric 7610b57cec5SDimitry Andricclass MUBUF_AtomicRet_Pseudo<string opName, int addrKind, 7620b57cec5SDimitry Andric RegisterClass vdataClass, 763*0fca6ea1SDimitry Andric bit hasRestrictedSOffset = 0, 7640b57cec5SDimitry Andric list<dag> pattern=[], 7650b57cec5SDimitry Andric // Workaround bug bz30254 7660b57cec5SDimitry Andric int addrKindCopy = addrKind, 767fe6060f1SDimitry Andric RegisterClass vdataClassCopy = vdataClass, 768fe6060f1SDimitry Andric RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret> 7690b57cec5SDimitry Andric : MUBUF_Atomic_Pseudo<opName, addrKindCopy, 770fe6060f1SDimitry Andric (outs vdata_op:$vdata), 771*0fca6ea1SDimitry Andric getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 1, hasRestrictedSOffset>.ret, 772bdd1243dSDimitry Andric getMUBUFAsmOps<addrKindCopy>.ret, 773*0fca6ea1SDimitry Andric pattern> { 7740b57cec5SDimitry Andric let PseudoInstr = opName # "_rtn_" # getAddrName<addrKindCopy>.ret; 7750b57cec5SDimitry Andric let glc_value = 1; 7760b57cec5SDimitry Andric let dlc_value = 0; 777fe6060f1SDimitry Andric let sccb_value = 0; 778fe6060f1SDimitry Andric let IsAtomicRet = 1; 7790b57cec5SDimitry Andric let Constraints = "$vdata = $vdata_in"; 7800b57cec5SDimitry Andric let DisableEncoding = "$vdata_in"; 7810b57cec5SDimitry Andric} 7820b57cec5SDimitry Andric 7830b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics_NO_RTN <string opName, 7840b57cec5SDimitry Andric RegisterClass vdataClass, 7857a6dacacSDimitry Andric ValueType vdataType> { 7867a6dacacSDimitry Andric let FPAtomic = vdataType.isFP in { 7875f757f3fSDimitry Andric def _OFFSET : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass, 0>, 7880b57cec5SDimitry Andric MUBUFAddr64Table <0, NAME>; 7895f757f3fSDimitry Andric def _ADDR64 : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, 0>, 7900b57cec5SDimitry Andric MUBUFAddr64Table <1, NAME>; 7915f757f3fSDimitry Andric def _OFFEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, 0>; 7925f757f3fSDimitry Andric def _IDXEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, 0>; 7935f757f3fSDimitry Andric def _BOTHEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, 0>; 7945f757f3fSDimitry Andric 7955f757f3fSDimitry Andric def _VBUFFER_OFFSET : MUBUF_AtomicNoRet_Pseudo <opName #_vbuffer, BUFAddrKind.Offset, vdataClass, 1>, 7965f757f3fSDimitry Andric MUBUFAddr64Table <0, NAME # "_VBUFFER">; 7975f757f3fSDimitry Andric def _VBUFFER_ADDR64 : MUBUF_AtomicNoRet_Pseudo <opName #_vbuffer, BUFAddrKind.Addr64, vdataClass, 1>, 7985f757f3fSDimitry Andric MUBUFAddr64Table <1, NAME # "_VBUFFER">; 7995f757f3fSDimitry Andric def _VBUFFER_OFFEN : MUBUF_AtomicNoRet_Pseudo <opName #_vbuffer, BUFAddrKind.OffEn, vdataClass, 1>; 8005f757f3fSDimitry Andric def _VBUFFER_IDXEN : MUBUF_AtomicNoRet_Pseudo <opName #_vbuffer, BUFAddrKind.IdxEn, vdataClass, 1>; 8015f757f3fSDimitry Andric def _VBUFFER_BOTHEN : MUBUF_AtomicNoRet_Pseudo <opName #_vbuffer, BUFAddrKind.BothEn, vdataClass, 1>; 8020b57cec5SDimitry Andric } 80306c3fb27SDimitry Andric} 8040b57cec5SDimitry Andric 8050b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics_RTN <string opName, 8060b57cec5SDimitry Andric RegisterClass vdataClass, 8070b57cec5SDimitry Andric ValueType vdataType, 8087a6dacacSDimitry Andric SDPatternOperator atomic> { 8097a6dacacSDimitry Andric let FPAtomic = vdataType.isFP in { 8105f757f3fSDimitry Andric def _OFFSET_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass, 0, 8110b57cec5SDimitry Andric [(set vdataType:$vdata, 81206c3fb27SDimitry Andric (atomic (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset), 8130b57cec5SDimitry Andric vdataType:$vdata_in))]>, 8140b57cec5SDimitry Andric MUBUFAddr64Table <0, NAME # "_RTN">; 8150b57cec5SDimitry Andric 8165f757f3fSDimitry Andric def _ADDR64_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, 0, 8170b57cec5SDimitry Andric [(set vdataType:$vdata, 81806c3fb27SDimitry Andric (atomic (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset), 8190b57cec5SDimitry Andric vdataType:$vdata_in))]>, 8200b57cec5SDimitry Andric MUBUFAddr64Table <1, NAME # "_RTN">; 8210b57cec5SDimitry Andric 8225f757f3fSDimitry Andric def _OFFEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, 0>; 8235f757f3fSDimitry Andric def _IDXEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, 0>; 8245f757f3fSDimitry Andric def _BOTHEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, 0>; 8255f757f3fSDimitry Andric 8265f757f3fSDimitry Andric def _VBUFFER_OFFSET_RTN : MUBUF_AtomicRet_Pseudo <opName #_vbuffer, BUFAddrKind.Offset, vdataClass, 1, 8275f757f3fSDimitry Andric [(set vdataType:$vdata, 8285f757f3fSDimitry Andric (atomic (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset), 8295f757f3fSDimitry Andric vdataType:$vdata_in))]>, 8305f757f3fSDimitry Andric MUBUFAddr64Table <0, NAME # "_VBUFFER_RTN">; 8315f757f3fSDimitry Andric 8325f757f3fSDimitry Andric def _VBUFFER_ADDR64_RTN : MUBUF_AtomicRet_Pseudo <opName #_vbuffer, BUFAddrKind.Addr64, vdataClass, 1, 8335f757f3fSDimitry Andric [(set vdataType:$vdata, 8345f757f3fSDimitry Andric (atomic (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset), 8355f757f3fSDimitry Andric vdataType:$vdata_in))]>, 8365f757f3fSDimitry Andric MUBUFAddr64Table <1, NAME # "_VBUFFER_RTN">; 8375f757f3fSDimitry Andric 8385f757f3fSDimitry Andric def _VBUFFER_OFFEN_RTN : MUBUF_AtomicRet_Pseudo <opName #_vbuffer, BUFAddrKind.OffEn, vdataClass, 1>; 8395f757f3fSDimitry Andric def _VBUFFER_IDXEN_RTN : MUBUF_AtomicRet_Pseudo <opName #_vbuffer, BUFAddrKind.IdxEn, vdataClass, 1>; 8405f757f3fSDimitry Andric def _VBUFFER_BOTHEN_RTN : MUBUF_AtomicRet_Pseudo <opName #_vbuffer, BUFAddrKind.BothEn, vdataClass, 1>; 8410b57cec5SDimitry Andric } 84206c3fb27SDimitry Andric} 8430b57cec5SDimitry Andric 8440b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics <string opName, 8450b57cec5SDimitry Andric RegisterClass vdataClass, 8460b57cec5SDimitry Andric ValueType vdataType, 84781ad6265SDimitry Andric SDPatternOperator atomic = null_frag> : 848349cc55cSDimitry Andric MUBUF_Pseudo_Atomics_NO_RTN<opName, vdataClass, vdataType>, 8490b57cec5SDimitry Andric MUBUF_Pseudo_Atomics_RTN<opName, vdataClass, vdataType, atomic>; 8500b57cec5SDimitry Andric 8510b57cec5SDimitry Andric 8520b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 8530b57cec5SDimitry Andric// MUBUF Instructions 8540b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 8550b57cec5SDimitry Andric 8560b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X : MUBUF_Pseudo_Loads_Lds < 8578bcb0991SDimitry Andric "buffer_load_format_x", f32 8580b57cec5SDimitry Andric>; 8590b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY : MUBUF_Pseudo_Loads < 8608bcb0991SDimitry Andric "buffer_load_format_xy", v2f32 8610b57cec5SDimitry Andric>; 8620b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Pseudo_Loads < 8638bcb0991SDimitry Andric "buffer_load_format_xyz", v3f32 8640b57cec5SDimitry Andric>; 8650b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Pseudo_Loads < 8668bcb0991SDimitry Andric "buffer_load_format_xyzw", v4f32 8670b57cec5SDimitry Andric>; 8680b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X : MUBUF_Pseudo_Stores < 8698bcb0991SDimitry Andric "buffer_store_format_x", f32 8700b57cec5SDimitry Andric>; 8710b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY : MUBUF_Pseudo_Stores < 8728bcb0991SDimitry Andric "buffer_store_format_xy", v2f32 8730b57cec5SDimitry Andric>; 8740b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ : MUBUF_Pseudo_Stores < 8758bcb0991SDimitry Andric "buffer_store_format_xyz", v3f32 8760b57cec5SDimitry Andric>; 8770b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Pseudo_Stores < 8788bcb0991SDimitry Andric "buffer_store_format_xyzw", v4f32 8790b57cec5SDimitry Andric>; 8800b57cec5SDimitry Andric 8815f757f3fSDimitry Andriclet OtherPredicates = [HasUnpackedD16VMem], D16Buf = 1 in { 882bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in { 8830b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Loads < 8848bcb0991SDimitry Andric "buffer_load_format_d16_x", i32 8850b57cec5SDimitry Andric >; 8860b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Loads < 8878bcb0991SDimitry Andric "buffer_load_format_d16_xy", v2i32 8880b57cec5SDimitry Andric >; 8890b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Loads < 8908bcb0991SDimitry Andric "buffer_load_format_d16_xyz", v3i32 8910b57cec5SDimitry Andric >; 8920b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Loads < 8938bcb0991SDimitry Andric "buffer_load_format_d16_xyzw", v4i32 8940b57cec5SDimitry Andric >; 895bdd1243dSDimitry Andric} 8960b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Stores < 8978bcb0991SDimitry Andric "buffer_store_format_d16_x", i32 8980b57cec5SDimitry Andric >; 8990b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Stores < 9008bcb0991SDimitry Andric "buffer_store_format_d16_xy", v2i32 9010b57cec5SDimitry Andric >; 9020b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Stores < 9038bcb0991SDimitry Andric "buffer_store_format_d16_xyz", v3i32 9040b57cec5SDimitry Andric >; 9050b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Stores < 9068bcb0991SDimitry Andric "buffer_store_format_d16_xyzw", v4i32 9070b57cec5SDimitry Andric >; 9085f757f3fSDimitry Andric} // End OtherPredicates = [HasUnpackedD16VMem], D16Buf = 1. 9090b57cec5SDimitry Andric 9105f757f3fSDimitry Andriclet OtherPredicates = [HasPackedD16VMem], D16Buf = 1 in { 911bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in { 9120b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Pseudo_Loads < 9138bcb0991SDimitry Andric "buffer_load_format_d16_x", f16 9140b57cec5SDimitry Andric >; 9150b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Pseudo_Loads < 9168bcb0991SDimitry Andric "buffer_load_format_d16_xy", v2f16 9170b57cec5SDimitry Andric >; 9180b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Pseudo_Loads < 9198bcb0991SDimitry Andric "buffer_load_format_d16_xyz", v3f16 9200b57cec5SDimitry Andric >; 9210b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Pseudo_Loads < 9228bcb0991SDimitry Andric "buffer_load_format_d16_xyzw", v4f16 9230b57cec5SDimitry Andric >; 924bdd1243dSDimitry Andric} 9250b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_X : MUBUF_Pseudo_Stores < 9268bcb0991SDimitry Andric "buffer_store_format_d16_x", f16 9270b57cec5SDimitry Andric >; 9280b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Pseudo_Stores < 9298bcb0991SDimitry Andric "buffer_store_format_d16_xy", v2f16 9300b57cec5SDimitry Andric >; 9310b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Pseudo_Stores < 9328bcb0991SDimitry Andric "buffer_store_format_d16_xyz", v3f16 9330b57cec5SDimitry Andric >; 9340b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Pseudo_Stores < 9358bcb0991SDimitry Andric "buffer_store_format_d16_xyzw", v4f16 9360b57cec5SDimitry Andric >; 9375f757f3fSDimitry Andric} // End OtherPredicates = [HasPackedD16VMem], D16Buf = 1. 9380b57cec5SDimitry Andric 9390b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE : MUBUF_Pseudo_Loads_Lds < 9408bcb0991SDimitry Andric "buffer_load_ubyte", i32 9410b57cec5SDimitry Andric>; 9420b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE : MUBUF_Pseudo_Loads_Lds < 9438bcb0991SDimitry Andric "buffer_load_sbyte", i32 9440b57cec5SDimitry Andric>; 9450b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT : MUBUF_Pseudo_Loads_Lds < 9468bcb0991SDimitry Andric "buffer_load_ushort", i32 9470b57cec5SDimitry Andric>; 9480b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT : MUBUF_Pseudo_Loads_Lds < 9498bcb0991SDimitry Andric "buffer_load_sshort", i32 9500b57cec5SDimitry Andric>; 9510b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD : MUBUF_Pseudo_Loads_Lds < 9528bcb0991SDimitry Andric "buffer_load_dword", i32 9530b57cec5SDimitry Andric>; 9540b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2 : MUBUF_Pseudo_Loads < 9558bcb0991SDimitry Andric "buffer_load_dwordx2", v2i32 9560b57cec5SDimitry Andric>; 9570b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3 : MUBUF_Pseudo_Loads < 9588bcb0991SDimitry Andric "buffer_load_dwordx3", v3i32 9590b57cec5SDimitry Andric>; 9600b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4 : MUBUF_Pseudo_Loads < 9618bcb0991SDimitry Andric "buffer_load_dwordx4", v4i32 9620b57cec5SDimitry Andric>; 9630b57cec5SDimitry Andric 96481ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_B32 : MUBUF_Pseudo_Loads_LDSOpc < 96581ad6265SDimitry Andric "buffer_load_lds_b32", i32 96681ad6265SDimitry Andric>; 96781ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_FORMAT_X : MUBUF_Pseudo_Loads_LDSOpc < 96881ad6265SDimitry Andric "buffer_load_lds_format_x", f32 96981ad6265SDimitry Andric>; 97081ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_I8 : MUBUF_Pseudo_Loads_LDSOpc < 97181ad6265SDimitry Andric "buffer_load_lds_i8", i32 97281ad6265SDimitry Andric>; 97381ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_I16 : MUBUF_Pseudo_Loads_LDSOpc < 97481ad6265SDimitry Andric "buffer_load_lds_i16", i32 97581ad6265SDimitry Andric>; 97681ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_U8 : MUBUF_Pseudo_Loads_LDSOpc < 97781ad6265SDimitry Andric "buffer_load_lds_u8", i32 97881ad6265SDimitry Andric>; 97981ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_U16 : MUBUF_Pseudo_Loads_LDSOpc < 98081ad6265SDimitry Andric "buffer_load_lds_u16", i32 98181ad6265SDimitry Andric>; 98281ad6265SDimitry Andric 98381ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, atomic_load_8_global>; 98481ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, atomic_load_16_global>; 98581ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i16, atomic_load_8_global>; 98681ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i16, atomic_load_16_global>; 9870b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, extloadi8_global>; 9880b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, zextloadi8_global>; 9890b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_SBYTE", i32, sextloadi8_global>; 9900b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, extloadi16_global>; 9910b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, zextloadi16_global>; 9920b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_SSHORT", i32, sextloadi16_global>; 9935f757f3fSDimitry Andric 9945f757f3fSDimitry Andricforeach vt = Reg32Types.types in { 9955f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORD", vt, load_global>; 9965f757f3fSDimitry Andric} 9975f757f3fSDimitry Andric 9985f757f3fSDimitry Andricforeach vt = VReg_64.RegTypes in { 9995f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX2", vt, load_global>; 10005f757f3fSDimitry Andric} 10015f757f3fSDimitry Andric 10025f757f3fSDimitry Andricforeach vt = VReg_96.RegTypes in { 10035f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX3", vt, load_global>; 10045f757f3fSDimitry Andric} 10055f757f3fSDimitry Andric 10065f757f3fSDimitry Andricforeach vt = VReg_128.RegTypes in { 10075f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX4", vt, load_global>; 10085f757f3fSDimitry Andric} 10090b57cec5SDimitry Andric 10100b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE : MUBUF_Pseudo_Stores < 10115f757f3fSDimitry Andric "buffer_store_byte", i32 10120b57cec5SDimitry Andric>; 10130b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT : MUBUF_Pseudo_Stores < 10145f757f3fSDimitry Andric "buffer_store_short", i32 10150b57cec5SDimitry Andric>; 10160b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD : MUBUF_Pseudo_Stores < 10175f757f3fSDimitry Andric "buffer_store_dword", i32 10180b57cec5SDimitry Andric>; 10190b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2 : MUBUF_Pseudo_Stores < 10205f757f3fSDimitry Andric "buffer_store_dwordx2", v2i32 10210b57cec5SDimitry Andric>; 10220b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3 : MUBUF_Pseudo_Stores < 10235f757f3fSDimitry Andric "buffer_store_dwordx3", v3i32 10240b57cec5SDimitry Andric>; 10250b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4 : MUBUF_Pseudo_Stores < 10265f757f3fSDimitry Andric "buffer_store_dwordx4", v4i32 10270b57cec5SDimitry Andric>; 10285f757f3fSDimitry Andric 10295f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Store_Pats<"BUFFER_STORE_BYTE", i32, truncstorei8_global>; 10305f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Store_Pats<"BUFFER_STORE_SHORT", i32, truncstorei16_global>; 10315f757f3fSDimitry Andric 10325f757f3fSDimitry Andricforeach vt = Reg32Types.types in { 10335f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Store_Pats<"BUFFER_STORE_DWORD", vt, store_global>; 10345f757f3fSDimitry Andric} 10355f757f3fSDimitry Andric 10365f757f3fSDimitry Andricforeach vt = VReg_64.RegTypes in { 10375f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Store_Pats<"BUFFER_STORE_DWORDX2", vt, store_global>; 10385f757f3fSDimitry Andric} 10395f757f3fSDimitry Andric 10405f757f3fSDimitry Andricforeach vt = VReg_96.RegTypes in { 10415f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Store_Pats<"BUFFER_STORE_DWORDX3", vt, store_global>; 10425f757f3fSDimitry Andric} 10435f757f3fSDimitry Andric 10445f757f3fSDimitry Andricforeach vt = VReg_128.RegTypes in { 10455f757f3fSDimitry Andricdefm : MUBUF_Pseudo_Store_Pats<"BUFFER_STORE_DWORDX4", vt, store_global>; 10465f757f3fSDimitry Andric} 10475f757f3fSDimitry Andric 10480b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP : MUBUF_Pseudo_Atomics < 104981ad6265SDimitry Andric "buffer_atomic_swap", VGPR_32, i32 10500b57cec5SDimitry Andric>; 10510b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP : MUBUF_Pseudo_Atomics < 105281ad6265SDimitry Andric "buffer_atomic_cmpswap", VReg_64, v2i32 10530b57cec5SDimitry Andric>; 10540b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD : MUBUF_Pseudo_Atomics < 105581ad6265SDimitry Andric "buffer_atomic_add", VGPR_32, i32 10560b57cec5SDimitry Andric>; 10570b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB : MUBUF_Pseudo_Atomics < 105881ad6265SDimitry Andric "buffer_atomic_sub", VGPR_32, i32 10590b57cec5SDimitry Andric>; 10600b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN : MUBUF_Pseudo_Atomics < 106181ad6265SDimitry Andric "buffer_atomic_smin", VGPR_32, i32 10620b57cec5SDimitry Andric>; 10630b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN : MUBUF_Pseudo_Atomics < 106481ad6265SDimitry Andric "buffer_atomic_umin", VGPR_32, i32 10650b57cec5SDimitry Andric>; 10660b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX : MUBUF_Pseudo_Atomics < 106781ad6265SDimitry Andric "buffer_atomic_smax", VGPR_32, i32 10680b57cec5SDimitry Andric>; 10690b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX : MUBUF_Pseudo_Atomics < 107081ad6265SDimitry Andric "buffer_atomic_umax", VGPR_32, i32 10710b57cec5SDimitry Andric>; 10720b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND : MUBUF_Pseudo_Atomics < 107381ad6265SDimitry Andric "buffer_atomic_and", VGPR_32, i32 10740b57cec5SDimitry Andric>; 10750b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR : MUBUF_Pseudo_Atomics < 107681ad6265SDimitry Andric "buffer_atomic_or", VGPR_32, i32 10770b57cec5SDimitry Andric>; 10780b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR : MUBUF_Pseudo_Atomics < 107981ad6265SDimitry Andric "buffer_atomic_xor", VGPR_32, i32 10800b57cec5SDimitry Andric>; 10810b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC : MUBUF_Pseudo_Atomics < 108281ad6265SDimitry Andric "buffer_atomic_inc", VGPR_32, i32 10830b57cec5SDimitry Andric>; 10840b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC : MUBUF_Pseudo_Atomics < 108581ad6265SDimitry Andric "buffer_atomic_dec", VGPR_32, i32 10860b57cec5SDimitry Andric>; 10870b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Pseudo_Atomics < 108881ad6265SDimitry Andric "buffer_atomic_swap_x2", VReg_64, i64 10890b57cec5SDimitry Andric>; 10900b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Pseudo_Atomics < 109181ad6265SDimitry Andric "buffer_atomic_cmpswap_x2", VReg_128, v2i64 10920b57cec5SDimitry Andric>; 10930b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2 : MUBUF_Pseudo_Atomics < 109481ad6265SDimitry Andric "buffer_atomic_add_x2", VReg_64, i64 10950b57cec5SDimitry Andric>; 10960b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2 : MUBUF_Pseudo_Atomics < 109781ad6265SDimitry Andric "buffer_atomic_sub_x2", VReg_64, i64 10980b57cec5SDimitry Andric>; 10990b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Pseudo_Atomics < 110081ad6265SDimitry Andric "buffer_atomic_smin_x2", VReg_64, i64 11010b57cec5SDimitry Andric>; 11020b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Pseudo_Atomics < 110381ad6265SDimitry Andric "buffer_atomic_umin_x2", VReg_64, i64 11040b57cec5SDimitry Andric>; 11050b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Pseudo_Atomics < 110681ad6265SDimitry Andric "buffer_atomic_smax_x2", VReg_64, i64 11070b57cec5SDimitry Andric>; 11080b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Pseudo_Atomics < 110981ad6265SDimitry Andric "buffer_atomic_umax_x2", VReg_64, i64 11100b57cec5SDimitry Andric>; 11110b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2 : MUBUF_Pseudo_Atomics < 111281ad6265SDimitry Andric "buffer_atomic_and_x2", VReg_64, i64 11130b57cec5SDimitry Andric>; 11140b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2 : MUBUF_Pseudo_Atomics < 111581ad6265SDimitry Andric "buffer_atomic_or_x2", VReg_64, i64 11160b57cec5SDimitry Andric>; 11170b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2 : MUBUF_Pseudo_Atomics < 111881ad6265SDimitry Andric "buffer_atomic_xor_x2", VReg_64, i64 11190b57cec5SDimitry Andric>; 11200b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2 : MUBUF_Pseudo_Atomics < 112181ad6265SDimitry Andric "buffer_atomic_inc_x2", VReg_64, i64 11220b57cec5SDimitry Andric>; 11230b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2 : MUBUF_Pseudo_Atomics < 112481ad6265SDimitry Andric "buffer_atomic_dec_x2", VReg_64, i64 11250b57cec5SDimitry Andric>; 11260b57cec5SDimitry Andric 11275f757f3fSDimitry Andriclet OtherPredicates = [HasGFX10_BEncoding] in { 11285f757f3fSDimitry Andric defm BUFFER_ATOMIC_CSUB : MUBUF_Pseudo_Atomics < 1129e8d8bef9SDimitry Andric "buffer_atomic_csub", VGPR_32, i32, int_amdgcn_global_atomic_csub 11305ffd83dbSDimitry Andric >; 11315f757f3fSDimitry Andric} 11325ffd83dbSDimitry Andric 11330b57cec5SDimitry Andriclet SubtargetPredicate = isGFX8GFX9 in { 11340b57cec5SDimitry Andricdef BUFFER_STORE_LDS_DWORD : MUBUF_Pseudo_Store_Lds <"buffer_store_lds_dword">; 11350b57cec5SDimitry Andric} 11360b57cec5SDimitry Andric 11370b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6 in { // isn't on CI & VI 11380b57cec5SDimitry Andric/* 11390b57cec5SDimitry Andricdefm BUFFER_ATOMIC_RSUB : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub">; 11400b57cec5SDimitry Andricdefm BUFFER_ATOMIC_RSUB_X2 : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub_x2">; 11410b57cec5SDimitry Andric*/ 11420b57cec5SDimitry Andric 11430b57cec5SDimitry Andricdef BUFFER_WBINVL1_SC : MUBUF_Invalidate <"buffer_wbinvl1_sc", 11440b57cec5SDimitry Andric int_amdgcn_buffer_wbinvl1_sc>; 11450b57cec5SDimitry Andric} 11460b57cec5SDimitry Andric 114781ad6265SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10Plus in { 11488bcb0991SDimitry Andric 11498bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP : MUBUF_Pseudo_Atomics < 11508bcb0991SDimitry Andric "buffer_atomic_fcmpswap", VReg_64, v2f32, null_frag 11518bcb0991SDimitry Andric>; 1152*0fca6ea1SDimitry Andric} 1153*0fca6ea1SDimitry Andric 1154*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFMinFMaxF32GlobalInsts in { 11558bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN : MUBUF_Pseudo_Atomics < 11568bcb0991SDimitry Andric "buffer_atomic_fmin", VGPR_32, f32, null_frag 11578bcb0991SDimitry Andric>; 11588bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX : MUBUF_Pseudo_Atomics < 11598bcb0991SDimitry Andric "buffer_atomic_fmax", VGPR_32, f32, null_frag 11608bcb0991SDimitry Andric>; 116181ad6265SDimitry Andric} 116281ad6265SDimitry Andric 116381ad6265SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10 in { 11648bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Pseudo_Atomics < 11658bcb0991SDimitry Andric "buffer_atomic_fcmpswap_x2", VReg_128, v2f64, null_frag 11668bcb0991SDimitry Andric>; 11678bcb0991SDimitry Andric} 11688bcb0991SDimitry Andric 11690b57cec5SDimitry Andriclet SubtargetPredicate = HasD16LoadStore in { 1170bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in { 11710b57cec5SDimitry Andric 11720b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16 : MUBUF_Pseudo_Loads < 1173349cc55cSDimitry Andric "buffer_load_ubyte_d16", i32, 1 11740b57cec5SDimitry Andric>; 11750b57cec5SDimitry Andric 11760b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Pseudo_Loads < 1177349cc55cSDimitry Andric "buffer_load_ubyte_d16_hi", i32, 1 11780b57cec5SDimitry Andric>; 11790b57cec5SDimitry Andric 11800b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16 : MUBUF_Pseudo_Loads < 1181349cc55cSDimitry Andric "buffer_load_sbyte_d16", i32, 1 11820b57cec5SDimitry Andric>; 11830b57cec5SDimitry Andric 11840b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Pseudo_Loads < 1185349cc55cSDimitry Andric "buffer_load_sbyte_d16_hi", i32, 1 11860b57cec5SDimitry Andric>; 11870b57cec5SDimitry Andric 11880b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16 : MUBUF_Pseudo_Loads < 1189349cc55cSDimitry Andric "buffer_load_short_d16", i32, 1 11900b57cec5SDimitry Andric>; 11910b57cec5SDimitry Andric 11920b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Pseudo_Loads < 1193349cc55cSDimitry Andric "buffer_load_short_d16_hi", i32, 1 11940b57cec5SDimitry Andric>; 11950b57cec5SDimitry Andric 1196bdd1243dSDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Pseudo_Loads < 1197bdd1243dSDimitry Andric "buffer_load_format_d16_hi_x", i32 1198bdd1243dSDimitry Andric>; 1199bdd1243dSDimitry Andric} // End TiedSourceNotRead 1200bdd1243dSDimitry Andric 12010b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI : MUBUF_Pseudo_Stores < 12028bcb0991SDimitry Andric "buffer_store_byte_d16_hi", i32 12030b57cec5SDimitry Andric>; 12040b57cec5SDimitry Andric 12050b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI : MUBUF_Pseudo_Stores < 12068bcb0991SDimitry Andric "buffer_store_short_d16_hi", i32 12070b57cec5SDimitry Andric>; 12080b57cec5SDimitry Andric 12090b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Pseudo_Stores < 12108bcb0991SDimitry Andric "buffer_store_format_d16_hi_x", i32 12110b57cec5SDimitry Andric>; 12120b57cec5SDimitry Andric 12130b57cec5SDimitry Andric} // End HasD16LoadStore 12140b57cec5SDimitry Andric 12151db9f3b2SDimitry Andriclet SubtargetPredicate = isNotGFX12Plus in 12161db9f3b2SDimitry Andricdef BUFFER_WBINVL1 : MUBUF_Invalidate < 12171db9f3b2SDimitry Andric "buffer_wbinvl1", int_amdgcn_buffer_wbinvl1 12181db9f3b2SDimitry Andric>; 12190b57cec5SDimitry Andric 122081ad6265SDimitry Andriclet SubtargetPredicate = HasAtomicFaddNoRtnInsts in 12210b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32 : MUBUF_Pseudo_Atomics_NO_RTN< 1222349cc55cSDimitry Andric "buffer_atomic_add_f32", VGPR_32, f32 12230b57cec5SDimitry Andric>; 122481ad6265SDimitry Andric 122506c3fb27SDimitry Andriclet SubtargetPredicate = HasAtomicBufferGlobalPkAddF16NoRtnInsts in 12260b57cec5SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Pseudo_Atomics_NO_RTN < 1227349cc55cSDimitry Andric "buffer_atomic_pk_add_f16", VGPR_32, v2f16 12280b57cec5SDimitry Andric>; 1229fe6060f1SDimitry Andric 1230*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFaddRtnInsts in 1231fe6060f1SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32 : MUBUF_Pseudo_Atomics_RTN< 1232bdd1243dSDimitry Andric "buffer_atomic_add_f32", VGPR_32, f32, null_frag 1233fe6060f1SDimitry Andric>; 123481ad6265SDimitry Andric 1235*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicBufferGlobalPkAddF16Insts in 1236fe6060f1SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Pseudo_Atomics_RTN < 1237bdd1243dSDimitry Andric "buffer_atomic_pk_add_f16", VGPR_32, v2f16, null_frag 1238fe6060f1SDimitry Andric>; 12390b57cec5SDimitry Andric 12407a6dacacSDimitry Andriclet SubtargetPredicate = isGFX12Plus in { 12417a6dacacSDimitry Andricdefm BUFFER_ATOMIC_COND_SUB_U32 : MUBUF_Pseudo_Atomics < 12427a6dacacSDimitry Andric "buffer_atomic_cond_sub_u32", VGPR_32, i32 12437a6dacacSDimitry Andric>; 1244*0fca6ea1SDimitry Andric} 12457a6dacacSDimitry Andric 1246*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicBufferPkAddBF16Inst in { 12477a6dacacSDimitry Andriclet FPAtomic = 1 in 12487a6dacacSDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_BF16 : MUBUF_Pseudo_Atomics < 12497a6dacacSDimitry Andric "buffer_atomic_pk_add_bf16", VGPR_32, v2bf16 12507a6dacacSDimitry Andric>; 12517a6dacacSDimitry Andric} 12527a6dacacSDimitry Andric 12530b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 12540b57cec5SDimitry Andric// MTBUF Instructions 12550b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 12560b57cec5SDimitry Andric 12578bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X : MTBUF_Pseudo_Loads <"tbuffer_load_format_x", VGPR_32, 1>; 12588bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY : MTBUF_Pseudo_Loads <"tbuffer_load_format_xy", VReg_64, 2>; 12598bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ : MTBUF_Pseudo_Loads <"tbuffer_load_format_xyz", VReg_96, 3>; 12608bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Pseudo_Loads <"tbuffer_load_format_xyzw", VReg_128, 4>; 12618bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_X : MTBUF_Pseudo_Stores <"tbuffer_store_format_x", VGPR_32, 1>; 12628bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY : MTBUF_Pseudo_Stores <"tbuffer_store_format_xy", VReg_64, 2>; 12638bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyz", VReg_96, 3>; 12648bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyzw", VReg_128, 4>; 12650b57cec5SDimitry Andric 12660b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem, D16Buf = 1 in { 1267bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in { 12688bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_X_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_x", VGPR_32, 1>; 12698bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xy", VReg_64, 2>; 12708bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyz", VReg_96, 3>; 12718bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyzw", VReg_128, 4>; 1272bdd1243dSDimitry Andric} 12738bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_X_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x", VGPR_32, 1>; 12748bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XY_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy", VReg_64, 2>; 12758bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz", VReg_96, 3>; 12768bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_128, 4>; 12770b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 12780b57cec5SDimitry Andric 12790b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem, D16Buf = 1 in { 1280bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in { 12818bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_X : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_x", VGPR_32, 1>; 12828bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XY : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xy", VGPR_32, 2>; 12838bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZ : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyz", VReg_64, 3>; 12848bcb0991SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZW : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyzw", VReg_64, 4>; 1285bdd1243dSDimitry Andric} 12868bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_X : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x", VGPR_32, 1>; 12878bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XY : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy", VGPR_32, 2>; 12888bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZ : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz", VReg_64, 3>; 12898bcb0991SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_64, 4>; 12900b57cec5SDimitry Andric} // End HasPackedD16VMem. 12910b57cec5SDimitry Andric 12920b57cec5SDimitry Andriclet SubtargetPredicate = isGFX7Plus in { 12930b57cec5SDimitry Andric 12940b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 12950b57cec5SDimitry Andric// Instruction definitions for CI and newer. 12960b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 12970b57cec5SDimitry Andric 12980b57cec5SDimitry Andricdef BUFFER_WBINVL1_VOL : MUBUF_Invalidate <"buffer_wbinvl1_vol", 12990b57cec5SDimitry Andric int_amdgcn_buffer_wbinvl1_vol>; 13000b57cec5SDimitry Andric 13010b57cec5SDimitry Andric} // End let SubtargetPredicate = isGFX7Plus 13020b57cec5SDimitry Andric 1303fe6060f1SDimitry Andriclet SubtargetPredicate = isGFX90APlus in { 1304fe6060f1SDimitry Andric def BUFFER_WBL2 : MUBUF_Invalidate<"buffer_wbl2"> { 130581ad6265SDimitry Andric let has_glc = 1; 130681ad6265SDimitry Andric let has_sccb = 1; 130781ad6265SDimitry Andric let InOperandList = (ins CPol_0:$cpol); 130881ad6265SDimitry Andric let AsmOperands = "$cpol"; 1309fe6060f1SDimitry Andric } 1310fe6060f1SDimitry Andric def BUFFER_INVL2 : MUBUF_Invalidate<"buffer_invl2"> { 131181ad6265SDimitry Andric let SubtargetPredicate = isGFX90AOnly; 1312fe6060f1SDimitry Andric } 1313*0fca6ea1SDimitry Andric} // End SubtargetPredicate = isGFX90APlus 1314fe6060f1SDimitry Andric 1315*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasFlatBufferGlobalAtomicFaddF64Inst in { 131681ad6265SDimitry Andric defm BUFFER_ATOMIC_ADD_F64 : MUBUF_Pseudo_Atomics<"buffer_atomic_add_f64", VReg_64, f64>; 1317*0fca6ea1SDimitry Andric} // End SubtargetPredicate = HasFlatBufferGlobalAtomicFaddF64Inst 1318*0fca6ea1SDimitry Andric 1319*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts in { 1320*0fca6ea1SDimitry Andric // Note the names can be buffer_atomic_fmin_x2/buffer_atomic_fmax_x2 1321*0fca6ea1SDimitry Andric // depending on some subtargets. 132281ad6265SDimitry Andric defm BUFFER_ATOMIC_MIN_F64 : MUBUF_Pseudo_Atomics<"buffer_atomic_min_f64", VReg_64, f64>; 132381ad6265SDimitry Andric defm BUFFER_ATOMIC_MAX_F64 : MUBUF_Pseudo_Atomics<"buffer_atomic_max_f64", VReg_64, f64>; 1324*0fca6ea1SDimitry Andric} 1325fe6060f1SDimitry Andric 132681ad6265SDimitry Andricdef BUFFER_INV : MUBUF_Invalidate<"buffer_inv"> { 132781ad6265SDimitry Andric let SubtargetPredicate = isGFX940Plus; 132881ad6265SDimitry Andric let has_glc = 1; 132981ad6265SDimitry Andric let has_sccb = 1; 133081ad6265SDimitry Andric let InOperandList = (ins CPol_0:$cpol); 133181ad6265SDimitry Andric let AsmOperands = "$cpol"; 133281ad6265SDimitry Andric} 133381ad6265SDimitry Andric 13340b57cec5SDimitry Andricdef BUFFER_GL0_INV : MUBUF_Invalidate<"buffer_gl0_inv">; 13350b57cec5SDimitry Andricdef BUFFER_GL1_INV : MUBUF_Invalidate<"buffer_gl1_inv">; 13360b57cec5SDimitry Andric 13370b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 13380b57cec5SDimitry Andric// MUBUF Patterns 13390b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 13400b57cec5SDimitry Andric 13410b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 13420b57cec5SDimitry Andric// buffer_load/store_format patterns 13430b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 13440b57cec5SDimitry Andric 13455f757f3fSDimitry Andricmulticlass MUBUF_LoadIntrinsicPat_Common<SDPatternOperator name, ValueType vt, 1346e8d8bef9SDimitry Andric string opcode, ValueType memoryVt = vt> { 1347fe6060f1SDimitry Andric defvar st = !if(!eq(memoryVt, vt), name, mubuf_intrinsic_load<name, memoryVt>); 1348e8d8bef9SDimitry Andric 13490b57cec5SDimitry Andric def : GCNPat< 13505f757f3fSDimitry Andric (vt (st v4i32:$rsrc, 0, 0, (BUFSOffset i32:$soffset), timm:$offset, 13518bcb0991SDimitry Andric timm:$auxiliary, 0)), 135206c3fb27SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _OFFSET) SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 1353bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 13540b57cec5SDimitry Andric >; 13550b57cec5SDimitry Andric 13560b57cec5SDimitry Andric def : GCNPat< 13575f757f3fSDimitry Andric (vt (st v4i32:$rsrc, 0, i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 13588bcb0991SDimitry Andric timm:$auxiliary, 0)), 135906c3fb27SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _OFFEN) VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 1360bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 13610b57cec5SDimitry Andric >; 13620b57cec5SDimitry Andric 13630b57cec5SDimitry Andric def : GCNPat< 13645f757f3fSDimitry Andric (vt (st v4i32:$rsrc, i32:$vindex, 0, (BUFSOffset i32:$soffset), timm:$offset, 13658bcb0991SDimitry Andric timm:$auxiliary, timm)), 136606c3fb27SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _IDXEN) VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 1367bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 13680b57cec5SDimitry Andric >; 13690b57cec5SDimitry Andric 13700b57cec5SDimitry Andric def : GCNPat< 13715f757f3fSDimitry Andric (vt (st v4i32:$rsrc, i32:$vindex, i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 13728bcb0991SDimitry Andric timm:$auxiliary, timm)), 13730b57cec5SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _BOTHEN) 13745ffd83dbSDimitry Andric (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1), 137506c3fb27SDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 1376bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 13770b57cec5SDimitry Andric >; 13780b57cec5SDimitry Andric} 13790b57cec5SDimitry Andric 13805f757f3fSDimitry Andricmulticlass MUBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt, 13815f757f3fSDimitry Andric string opcode, ValueType memoryVt = vt>{ 13825f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 13835f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<name, vt, opcode, memoryVt>; 13845f757f3fSDimitry Andric } 13855f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<name, vt, opcode # "_VBUFFER", memoryVt>; 13865f757f3fSDimitry Andric} 13875f757f3fSDimitry Andric 13880b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, f32, "BUFFER_LOAD_FORMAT_X">; 13890b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, i32, "BUFFER_LOAD_FORMAT_X">; 13900b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2f32, "BUFFER_LOAD_FORMAT_XY">; 13910b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2i32, "BUFFER_LOAD_FORMAT_XY">; 13920b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v3f32, "BUFFER_LOAD_FORMAT_XYZ">; 13930b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v3i32, "BUFFER_LOAD_FORMAT_XYZ">; 13940b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4f32, "BUFFER_LOAD_FORMAT_XYZW">; 13950b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4i32, "BUFFER_LOAD_FORMAT_XYZW">; 13960b57cec5SDimitry Andric 1397bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v2i32, "BUFFER_LOAD_FORMAT_X_TFE">; 1398bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v3i32, "BUFFER_LOAD_FORMAT_XY_TFE">; 1399bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v4i32, "BUFFER_LOAD_FORMAT_XYZ_TFE">; 1400bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v5i32, "BUFFER_LOAD_FORMAT_XYZW_TFE">; 1401bdd1243dSDimitry Andric 14025f757f3fSDimitry Andriclet OtherPredicates = [HasUnpackedD16VMem] in { 14035f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">; 14045f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">; 14055f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<SIbuffer_load_format_d16, i32, "BUFFER_LOAD_FORMAT_D16_X_gfx80">; 14065f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<SIbuffer_load_format_d16, v2i32, "BUFFER_LOAD_FORMAT_D16_XY_gfx80">; 14075f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<SIbuffer_load_format_d16, v3i32, "BUFFER_LOAD_FORMAT_D16_XYZ_gfx80">; 14085f757f3fSDimitry Andric defm : MUBUF_LoadIntrinsicPat_Common<SIbuffer_load_format_d16, v4i32, "BUFFER_LOAD_FORMAT_D16_XYZW_gfx80">; 14090b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 14100b57cec5SDimitry Andric 14115f757f3fSDimitry Andriclet OtherPredicates = [HasPackedD16VMem] in { 14120b57cec5SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X">; 14130b57cec5SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X">; 14145ffd83dbSDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i32, "BUFFER_LOAD_FORMAT_D16_X">; 14150b57cec5SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2f16, "BUFFER_LOAD_FORMAT_D16_XY">; 14160b57cec5SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2i16, "BUFFER_LOAD_FORMAT_D16_XY">; 1417e8d8bef9SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4f16, "BUFFER_LOAD_FORMAT_D16_XYZ", v3f16>; 1418e8d8bef9SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i16, "BUFFER_LOAD_FORMAT_D16_XYZ", v3i16>; 14190b57cec5SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4f16, "BUFFER_LOAD_FORMAT_D16_XYZW">; 14200b57cec5SDimitry Andric defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i16, "BUFFER_LOAD_FORMAT_D16_XYZW">; 14210b57cec5SDimitry Andric} // End HasPackedD16VMem. 14220b57cec5SDimitry Andric 1423*0fca6ea1SDimitry Andricforeach vt = Reg32Types.types in { 1424*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, vt, "BUFFER_LOAD_DWORD">; 1425*0fca6ea1SDimitry Andric} 1426*0fca6ea1SDimitry Andric 1427*0fca6ea1SDimitry Andricforeach vt = Reg64Types.types in { 1428*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, vt, "BUFFER_LOAD_DWORDX2">; 1429*0fca6ea1SDimitry Andric} 1430*0fca6ea1SDimitry Andric 1431*0fca6ea1SDimitry Andricforeach vt = Reg96Types.types in { 1432*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, vt, "BUFFER_LOAD_DWORDX3">; 1433*0fca6ea1SDimitry Andric} 1434*0fca6ea1SDimitry Andric 1435*0fca6ea1SDimitry Andricforeach vt = Reg128Types.types in { 1436*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, vt, "BUFFER_LOAD_DWORDX4">; 1437*0fca6ea1SDimitry Andric} 1438*0fca6ea1SDimitry Andric 14390b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_byte, i32, "BUFFER_LOAD_SBYTE">; 14400b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_short, i32, "BUFFER_LOAD_SSHORT">; 14410b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ubyte, i32, "BUFFER_LOAD_UBYTE">; 14420b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ushort, i32, "BUFFER_LOAD_USHORT">; 14430b57cec5SDimitry Andric 1444*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_tfe, v2i32, "BUFFER_LOAD_DWORD_TFE">; 1445*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_tfe, v3i32, "BUFFER_LOAD_DWORDX2_TFE">; 1446*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_tfe, v4i32, "BUFFER_LOAD_DWORDX3_TFE">; 1447*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_tfe, v5i32, "BUFFER_LOAD_DWORDX4_TFE">; 1448*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_byte_tfe, v2i32, "BUFFER_LOAD_SBYTE_TFE">; 1449*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_short_tfe, v2i32, "BUFFER_LOAD_SSHORT_TFE">; 1450*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ubyte_tfe, v2i32, "BUFFER_LOAD_UBYTE_TFE">; 1451*0fca6ea1SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ushort_tfe, v2i32, "BUFFER_LOAD_USHORT_TFE">; 1452*0fca6ea1SDimitry Andric 14535f757f3fSDimitry Andricmulticlass MUBUF_StoreIntrinsicPat_Common<SDPatternOperator name, ValueType vt, 1454e8d8bef9SDimitry Andric string opcode, ValueType memoryVt = vt> { 1455fe6060f1SDimitry Andric defvar st = !if(!eq(memoryVt, vt), name, mubuf_intrinsic_store<name, memoryVt>); 1456e8d8bef9SDimitry Andric 14570b57cec5SDimitry Andric def : GCNPat< 14585f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, 0, 0, (BUFSOffset i32:$soffset), timm:$offset, 14598bcb0991SDimitry Andric timm:$auxiliary, 0), 146006c3fb27SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _OFFSET_exact) getVregSrcForVT<vt>.ret:$vdata, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 1461bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 14620b57cec5SDimitry Andric >; 14630b57cec5SDimitry Andric 14640b57cec5SDimitry Andric def : GCNPat< 14655f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 14668bcb0991SDimitry Andric timm:$auxiliary, 0), 14675ffd83dbSDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _OFFEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, 146806c3fb27SDimitry Andric timm:$offset, (extract_cpol $auxiliary), (extract_swz $auxiliary)) 14690b57cec5SDimitry Andric >; 14700b57cec5SDimitry Andric 14710b57cec5SDimitry Andric def : GCNPat< 14725f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, (BUFSOffset i32:$soffset), timm:$offset, 14738bcb0991SDimitry Andric timm:$auxiliary, timm), 14745ffd83dbSDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _IDXEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, 147506c3fb27SDimitry Andric timm:$offset, (extract_cpol $auxiliary), (extract_swz $auxiliary)) 14760b57cec5SDimitry Andric >; 14770b57cec5SDimitry Andric 14780b57cec5SDimitry Andric def : GCNPat< 14795f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 14808bcb0991SDimitry Andric timm:$auxiliary, timm), 14810b57cec5SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _BOTHEN_exact) 14825ffd83dbSDimitry Andric getVregSrcForVT<vt>.ret:$vdata, 14835ffd83dbSDimitry Andric (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1), 148406c3fb27SDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, (extract_cpol $auxiliary), 1485bdd1243dSDimitry Andric (extract_swz $auxiliary)) 14860b57cec5SDimitry Andric >; 14870b57cec5SDimitry Andric} 14880b57cec5SDimitry Andric 14895f757f3fSDimitry Andricmulticlass MUBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt, 14905f757f3fSDimitry Andric string opcode, ValueType memoryVt = vt> { 14915f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 14925f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<name, vt, opcode, memoryVt>; 14935f757f3fSDimitry Andric } 14945f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<name, vt, opcode # "_VBUFFER", memoryVt>; 14955f757f3fSDimitry Andric} 14965f757f3fSDimitry Andric 14970b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, f32, "BUFFER_STORE_FORMAT_X">; 14980b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, i32, "BUFFER_STORE_FORMAT_X">; 14990b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2f32, "BUFFER_STORE_FORMAT_XY">; 15000b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2i32, "BUFFER_STORE_FORMAT_XY">; 1501*0fca6ea1SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2i32, "BUFFER_STORE_FORMAT_XY">; 15020b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v3f32, "BUFFER_STORE_FORMAT_XYZ">; 15030b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v3i32, "BUFFER_STORE_FORMAT_XYZ">; 15040b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4f32, "BUFFER_STORE_FORMAT_XYZW">; 15050b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4i32, "BUFFER_STORE_FORMAT_XYZW">; 15060b57cec5SDimitry Andric 15075f757f3fSDimitry Andriclet OtherPredicates = [HasUnpackedD16VMem] in { 15085f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X_gfx80">; 15095f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X_gfx80">; 15105f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<SIbuffer_store_format_d16, i32, "BUFFER_STORE_FORMAT_D16_X_gfx80">; 15115f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<SIbuffer_store_format_d16, v2i32, "BUFFER_STORE_FORMAT_D16_XY_gfx80">; 15125f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<SIbuffer_store_format_d16, v3i32, "BUFFER_STORE_FORMAT_D16_XYZ_gfx80">; 15135f757f3fSDimitry Andric defm : MUBUF_StoreIntrinsicPat_Common<SIbuffer_store_format_d16, v4i32, "BUFFER_STORE_FORMAT_D16_XYZW_gfx80">; 15140b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 15150b57cec5SDimitry Andric 15165f757f3fSDimitry Andriclet OtherPredicates = [HasPackedD16VMem] in { 15170b57cec5SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X">; 15180b57cec5SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X">; 15195ffd83dbSDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i32, "BUFFER_STORE_FORMAT_D16_X">; 15200b57cec5SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2f16, "BUFFER_STORE_FORMAT_D16_XY">; 15210b57cec5SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2i16, "BUFFER_STORE_FORMAT_D16_XY">; 1522e8d8bef9SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4f16, "BUFFER_STORE_FORMAT_D16_XYZ", v3f16>; 1523e8d8bef9SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i16, "BUFFER_STORE_FORMAT_D16_XYZ", v3i16>; 15240b57cec5SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4f16, "BUFFER_STORE_FORMAT_D16_XYZW">; 15250b57cec5SDimitry Andric defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i16, "BUFFER_STORE_FORMAT_D16_XYZW">; 15260b57cec5SDimitry Andric} // End HasPackedD16VMem. 15270b57cec5SDimitry Andric 1528*0fca6ea1SDimitry Andricforeach vt = Reg32Types.types in { 1529*0fca6ea1SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, vt, "BUFFER_STORE_DWORD">; 1530*0fca6ea1SDimitry Andric} 1531*0fca6ea1SDimitry Andric 1532*0fca6ea1SDimitry Andricforeach vt = Reg64Types.types in { 1533*0fca6ea1SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, vt, "BUFFER_STORE_DWORDX2">; 1534*0fca6ea1SDimitry Andric} 1535*0fca6ea1SDimitry Andric 1536*0fca6ea1SDimitry Andricforeach vt = Reg96Types.types in { 1537*0fca6ea1SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, vt, "BUFFER_STORE_DWORDX3">; 1538*0fca6ea1SDimitry Andric} 1539*0fca6ea1SDimitry Andric 1540*0fca6ea1SDimitry Andricforeach vt = Reg128Types.types in { 1541*0fca6ea1SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, vt, "BUFFER_STORE_DWORDX4">; 1542*0fca6ea1SDimitry Andric} 1543*0fca6ea1SDimitry Andric 15440b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_byte, i32, "BUFFER_STORE_BYTE">; 15450b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_short, i32, "BUFFER_STORE_SHORT">; 15460b57cec5SDimitry Andric 15470b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 15480b57cec5SDimitry Andric// buffer_atomic patterns 15490b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 15500b57cec5SDimitry Andric 15515f757f3fSDimitry Andricmulticlass BufferAtomicPat_Common<string OpPrefix, ValueType vt, string Inst, bit isIntr = 0> { 155281ad6265SDimitry Andric foreach RtnMode = ["ret", "noret"] in { 155381ad6265SDimitry Andric 1554753f127fSDimitry Andric defvar Op = !cast<SDPatternOperator>(OpPrefix 1555753f127fSDimitry Andric # !if(!eq(RtnMode, "ret"), "", "_noret") 1556*0fca6ea1SDimitry Andric # !if(isIntr, "", "_" # vt)); 155781ad6265SDimitry Andric defvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", ""); 155881ad6265SDimitry Andric 1559753f127fSDimitry Andric let AddedComplexity = !if(!eq(RtnMode, "ret"), 0, 1) in { 15600b57cec5SDimitry Andric def : GCNPat< 156106c3fb27SDimitry Andric (vt (Op (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset), vt:$vdata_in)), 156281ad6265SDimitry Andric (!cast<MUBUF_Pseudo>(Inst # "_OFFSET" # InstSuffix) getVregSrcForVT<vt>.ret:$vdata_in, 1563*0fca6ea1SDimitry Andric SReg_128:$srsrc, SCSrc_b32:$soffset, Offset:$offset) 15640b57cec5SDimitry Andric >; 15650b57cec5SDimitry Andric 15660b57cec5SDimitry Andric def : GCNPat< 156706c3fb27SDimitry Andric (vt (Op (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset), 156881ad6265SDimitry Andric vt:$vdata_in)), 156981ad6265SDimitry Andric (!cast<MUBUF_Pseudo>(Inst # "_ADDR64" # InstSuffix) getVregSrcForVT<vt>.ret:$vdata_in, 1570*0fca6ea1SDimitry Andric VReg_64:$vaddr, SReg_128:$srsrc, SCSrc_b32:$soffset, Offset:$offset) 15710b57cec5SDimitry Andric >; 1572753f127fSDimitry Andric } // end let AddedComplexity 15730b57cec5SDimitry Andric 157481ad6265SDimitry Andric } // end foreach RtnMode 15750b57cec5SDimitry Andric} 15760b57cec5SDimitry Andric 15775f757f3fSDimitry Andricmulticlass BufferAtomicPat<string OpPrefix, ValueType vt, string Inst, bit isIntr = 0> { 15785f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 15795f757f3fSDimitry Andric defm : BufferAtomicPat_Common<OpPrefix, vt, Inst, isIntr>; 15805f757f3fSDimitry Andric } 15815f757f3fSDimitry Andric defm : BufferAtomicPat_Common<OpPrefix, vt, Inst # "_VBUFFER", isIntr>; 15825f757f3fSDimitry Andric} 15835f757f3fSDimitry Andric 158481ad6265SDimitry Andricmulticlass BufferAtomicIntrPat<string OpPrefix, ValueType vt, string Inst> { 158581ad6265SDimitry Andric defm : BufferAtomicPat<OpPrefix, vt, Inst, /* isIntr */ 1>; 158681ad6265SDimitry Andric} 15870b57cec5SDimitry Andric 15885f757f3fSDimitry Andricmulticlass BufferAtomicCmpSwapPat_Common<ValueType vt, ValueType data_vt, string Inst> { 158981ad6265SDimitry Andric foreach RtnMode = ["ret", "noret"] in { 159081ad6265SDimitry Andric 1591753f127fSDimitry Andric defvar Op = !cast<SDPatternOperator>("AMDGPUatomic_cmp_swap_global" 1592753f127fSDimitry Andric # !if(!eq(RtnMode, "ret"), "", "_noret") 1593*0fca6ea1SDimitry Andric # "_" # vt); 159481ad6265SDimitry Andric defvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", ""); 15957a6dacacSDimitry Andric defvar data_vt_RC = getVregSrcForVT<data_vt>.ret.RegClass; 159681ad6265SDimitry Andric 1597753f127fSDimitry Andric let AddedComplexity = !if(!eq(RtnMode, "ret"), 0, 1) in { 159881ad6265SDimitry Andric defvar OffsetResDag = (!cast<MUBUF_Pseudo>(Inst # "_OFFSET" # InstSuffix) 15997a6dacacSDimitry Andric data_vt_RC:$vdata_in, SReg_128:$srsrc, SCSrc_b32:$soffset, 1600*0fca6ea1SDimitry Andric Offset:$offset); 160181ad6265SDimitry Andric def : GCNPat< 160206c3fb27SDimitry Andric (vt (Op (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset), data_vt:$vdata_in)), 160381ad6265SDimitry Andric !if(!eq(RtnMode, "ret"), 16047a6dacacSDimitry Andric (EXTRACT_SUBREG (vt (COPY_TO_REGCLASS OffsetResDag, data_vt_RC)), 160581ad6265SDimitry Andric !if(!eq(vt, i32), sub0, sub0_sub1)), 160681ad6265SDimitry Andric OffsetResDag) 160781ad6265SDimitry Andric >; 160881ad6265SDimitry Andric 160981ad6265SDimitry Andric defvar Addr64ResDag = (!cast<MUBUF_Pseudo>(Inst # "_ADDR64" # InstSuffix) 16107a6dacacSDimitry Andric data_vt_RC:$vdata_in, VReg_64:$vaddr, SReg_128:$srsrc, 1611*0fca6ea1SDimitry Andric SCSrc_b32:$soffset, Offset:$offset); 161281ad6265SDimitry Andric def : GCNPat< 161306c3fb27SDimitry Andric (vt (Op (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset), 161481ad6265SDimitry Andric data_vt:$vdata_in)), 161581ad6265SDimitry Andric !if(!eq(RtnMode, "ret"), 16167a6dacacSDimitry Andric (EXTRACT_SUBREG (vt (COPY_TO_REGCLASS Addr64ResDag, data_vt_RC)), 161781ad6265SDimitry Andric !if(!eq(vt, i32), sub0, sub0_sub1)), 161881ad6265SDimitry Andric Addr64ResDag) 161981ad6265SDimitry Andric >; 1620753f127fSDimitry Andric } // end let AddedComplexity 162181ad6265SDimitry Andric 162281ad6265SDimitry Andric } // end foreach RtnMode 162381ad6265SDimitry Andric} 162481ad6265SDimitry Andric 16255f757f3fSDimitry Andricmulticlass BufferAtomicCmpSwapPat<ValueType vt, ValueType data_vt, string Inst> { 16265f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 16275f757f3fSDimitry Andric defm : BufferAtomicCmpSwapPat_Common<vt, data_vt, Inst>; 16285f757f3fSDimitry Andric } 16295f757f3fSDimitry Andric defm : BufferAtomicCmpSwapPat_Common<vt, data_vt, Inst # "_VBUFFER">; 16305f757f3fSDimitry Andric} 16315f757f3fSDimitry Andric 16325f757f3fSDimitry Andric 163381ad6265SDimitry Andricforeach Ty = [i32, i64] in { 163481ad6265SDimitry Andric 163581ad6265SDimitry Andricdefvar Suffix = !if(!eq(Ty, i64), "_X2", ""); 163681ad6265SDimitry Andric 163781ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_swap_global", Ty, "BUFFER_ATOMIC_SWAP" # Suffix>; 163881ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_add_global", Ty, "BUFFER_ATOMIC_ADD" # Suffix>; 163981ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_sub_global", Ty, "BUFFER_ATOMIC_SUB" # Suffix>; 164081ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_min_global", Ty, "BUFFER_ATOMIC_SMIN" # Suffix>; 164181ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_umin_global", Ty, "BUFFER_ATOMIC_UMIN" # Suffix>; 164281ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_max_global", Ty, "BUFFER_ATOMIC_SMAX" # Suffix>; 164381ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_umax_global", Ty, "BUFFER_ATOMIC_UMAX" # Suffix>; 164481ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_and_global", Ty, "BUFFER_ATOMIC_AND" # Suffix>; 164581ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_or_global", Ty, "BUFFER_ATOMIC_OR" # Suffix>; 164681ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_xor_global", Ty, "BUFFER_ATOMIC_XOR" # Suffix>; 164706c3fb27SDimitry Andricdefm : BufferAtomicPat<"atomic_load_uinc_wrap_global", Ty, "BUFFER_ATOMIC_INC" # Suffix>; 164806c3fb27SDimitry Andricdefm : BufferAtomicPat<"atomic_load_udec_wrap_global", Ty, "BUFFER_ATOMIC_DEC" # Suffix>; 164981ad6265SDimitry Andric 165081ad6265SDimitry Andric} // end foreach Ty 165181ad6265SDimitry Andric 1652*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFMinFMaxF32GlobalInsts in { 1653*0fca6ea1SDimitry Andricdefm : BufferAtomicPat<"atomic_load_fmin_global", f32, "BUFFER_ATOMIC_FMIN">; 1654*0fca6ea1SDimitry Andricdefm : BufferAtomicPat<"atomic_load_fmax_global", f32, "BUFFER_ATOMIC_FMAX">; 1655*0fca6ea1SDimitry Andric} 1656*0fca6ea1SDimitry Andric 1657*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts in { 1658*0fca6ea1SDimitry Andricdefm : BufferAtomicPat<"atomic_load_fmin_global", f64, "BUFFER_ATOMIC_MIN_F64">; 1659*0fca6ea1SDimitry Andricdefm : BufferAtomicPat<"atomic_load_fmax_global", f64, "BUFFER_ATOMIC_MAX_F64">; 1660*0fca6ea1SDimitry Andric} 1661*0fca6ea1SDimitry Andric 166281ad6265SDimitry Andricdefm : BufferAtomicCmpSwapPat<i32, v2i32, "BUFFER_ATOMIC_CMPSWAP">; 166381ad6265SDimitry Andricdefm : BufferAtomicCmpSwapPat<i64, v2i64, "BUFFER_ATOMIC_CMPSWAP_X2">; 166481ad6265SDimitry Andric 16655f757f3fSDimitry Andricmulticlass SIBufferAtomicPat_Common<string OpPrefix, ValueType vt, string Inst, 166681ad6265SDimitry Andric list<string> RtnModes = ["ret", "noret"]> { 166781ad6265SDimitry Andric foreach RtnMode = RtnModes in { 166881ad6265SDimitry Andric 1669753f127fSDimitry Andric defvar Op = !cast<SDPatternOperator>(OpPrefix 1670753f127fSDimitry Andric # !if(!eq(RtnMode, "ret"), "", "_noret")); 1671753f127fSDimitry Andric 1672753f127fSDimitry Andric defvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", ""); 1673753f127fSDimitry Andric defvar CachePolicy = !if(!eq(RtnMode, "ret"), 16747a6dacacSDimitry Andric (extract_cpol_set_glc $auxiliary), (extract_cpol $auxiliary)); 167581ad6265SDimitry Andric 1676753f127fSDimitry Andric let AddedComplexity = !if(!eq(RtnMode, "ret"), 0, 1) in { 167781ad6265SDimitry Andric def : GCNPat< 16785f757f3fSDimitry Andric (vt (Op vt:$vdata_in, v4i32:$rsrc, 0, 0, (BUFSOffset i32:$soffset), 16797a6dacacSDimitry Andric timm:$offset, timm:$auxiliary, 0)), 168081ad6265SDimitry Andric (!cast<MUBUF_Pseudo>(Inst # "_OFFSET" # InstSuffix) 168181ad6265SDimitry Andric getVregSrcForVT<vt>.ret:$vdata_in, SReg_128:$rsrc, SCSrc_b32:$soffset, 168206c3fb27SDimitry Andric timm:$offset, CachePolicy) 168381ad6265SDimitry Andric >; 168481ad6265SDimitry Andric 168581ad6265SDimitry Andric def : GCNPat< 16865f757f3fSDimitry Andric (vt (Op vt:$vdata_in, v4i32:$rsrc, i32:$vindex, 0, (BUFSOffset i32:$soffset), 16877a6dacacSDimitry Andric timm:$offset, timm:$auxiliary, timm)), 168881ad6265SDimitry Andric (!cast<MUBUF_Pseudo>(Inst # "_IDXEN" # InstSuffix) 168981ad6265SDimitry Andric getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$vindex, SReg_128:$rsrc, 169006c3fb27SDimitry Andric SCSrc_b32:$soffset, timm:$offset, CachePolicy) 169181ad6265SDimitry Andric >; 169281ad6265SDimitry Andric 169381ad6265SDimitry Andric def : GCNPat< 169481ad6265SDimitry Andric (vt (Op vt:$vdata_in, v4i32:$rsrc, 0, i32:$voffset, 16957a6dacacSDimitry Andric (BUFSOffset i32:$soffset), timm:$offset, timm:$auxiliary, 0)), 169681ad6265SDimitry Andric (!cast<MUBUF_Pseudo>(Inst # "_OFFEN" # InstSuffix) 169781ad6265SDimitry Andric getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$voffset, SReg_128:$rsrc, 169806c3fb27SDimitry Andric SCSrc_b32:$soffset, timm:$offset, CachePolicy) 169981ad6265SDimitry Andric >; 170081ad6265SDimitry Andric 170181ad6265SDimitry Andric def : GCNPat< 170281ad6265SDimitry Andric (vt (Op vt:$vdata_in, v4i32:$rsrc, i32:$vindex, i32:$voffset, 17037a6dacacSDimitry Andric (BUFSOffset i32:$soffset), timm:$offset, timm:$auxiliary, timm)), 170481ad6265SDimitry Andric (!cast<MUBUF_Pseudo>(Inst # "_BOTHEN" # InstSuffix) 170581ad6265SDimitry Andric getVregSrcForVT<vt>.ret:$vdata_in, 170681ad6265SDimitry Andric (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1), 170706c3fb27SDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, CachePolicy) 170881ad6265SDimitry Andric >; 1709753f127fSDimitry Andric } // end let AddedComplexity 171081ad6265SDimitry Andric 171181ad6265SDimitry Andric } // end foreach RtnMode 171281ad6265SDimitry Andric} 171381ad6265SDimitry Andric 17145f757f3fSDimitry Andricmulticlass SIBufferAtomicPat<string OpPrefix, ValueType vt, string Inst, 17155f757f3fSDimitry Andric list<string> RtnModes = ["ret", "noret"]> { 1716*0fca6ea1SDimitry Andric let OtherPredicates = [HasUnrestrictedSOffset] in { 17175f757f3fSDimitry Andric defm : SIBufferAtomicPat_Common<OpPrefix, vt, Inst, RtnModes>; 17185f757f3fSDimitry Andric } 1719*0fca6ea1SDimitry Andric 1720*0fca6ea1SDimitry Andric // FIXME: This needs a !HasUnrestrictedSOffset predicate 17215f757f3fSDimitry Andric defm : SIBufferAtomicPat_Common<OpPrefix, vt, Inst # "_VBUFFER", RtnModes>; 17225f757f3fSDimitry Andric} 17235f757f3fSDimitry Andric 172481ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_swap", i32, "BUFFER_ATOMIC_SWAP">; 172581ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_swap", f32, "BUFFER_ATOMIC_SWAP">; 172681ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_add", i32, "BUFFER_ATOMIC_ADD">; 172781ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_sub", i32, "BUFFER_ATOMIC_SUB">; 172881ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smin", i32, "BUFFER_ATOMIC_SMIN">; 172981ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umin", i32, "BUFFER_ATOMIC_UMIN">; 173081ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smax", i32, "BUFFER_ATOMIC_SMAX">; 173181ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umax", i32, "BUFFER_ATOMIC_UMAX">; 173281ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_and", i32, "BUFFER_ATOMIC_AND">; 173381ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_or", i32, "BUFFER_ATOMIC_OR">; 173481ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_xor", i32, "BUFFER_ATOMIC_XOR">; 173581ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_inc", i32, "BUFFER_ATOMIC_INC">; 173681ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_dec", i32, "BUFFER_ATOMIC_DEC">; 1737753f127fSDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_csub", i32, "BUFFER_ATOMIC_CSUB", ["ret"]>; 173881ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_swap", i64, "BUFFER_ATOMIC_SWAP_X2">; 173981ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_add", i64, "BUFFER_ATOMIC_ADD_X2">; 174081ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_sub", i64, "BUFFER_ATOMIC_SUB_X2">; 174181ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smin", i64, "BUFFER_ATOMIC_SMIN_X2">; 174281ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umin", i64, "BUFFER_ATOMIC_UMIN_X2">; 174381ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smax", i64, "BUFFER_ATOMIC_SMAX_X2">; 174481ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umax", i64, "BUFFER_ATOMIC_UMAX_X2">; 174581ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_and", i64, "BUFFER_ATOMIC_AND_X2">; 174681ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_or", i64, "BUFFER_ATOMIC_OR_X2">; 174781ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_xor", i64, "BUFFER_ATOMIC_XOR_X2">; 174881ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_inc", i64, "BUFFER_ATOMIC_INC_X2">; 174981ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_dec", i64, "BUFFER_ATOMIC_DEC_X2">; 175081ad6265SDimitry Andric 1751*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicCSubNoRtnInsts in 17525f757f3fSDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_csub", i32, "BUFFER_ATOMIC_CSUB", ["noret"]>; 17535f757f3fSDimitry Andric 1754*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicBufferPkAddBF16Inst in { 1755*0fca6ea1SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", v2bf16, "BUFFER_ATOMIC_PK_ADD_BF16">; 1756*0fca6ea1SDimitry Andric} 17577a6dacacSDimitry Andric 1758*0fca6ea1SDimitry Andriclet SubtargetPredicate = isGFX12Plus in { 1759*0fca6ea1SDimitry Andric defm : SIBufferAtomicPat_Common<"SIbuffer_atomic_cond_sub_u32", i32, "BUFFER_ATOMIC_COND_SUB_U32_VBUFFER", ["ret"]>; 1760*0fca6ea1SDimitry Andric} 1761*0fca6ea1SDimitry Andric 1762*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicCSubNoRtnInsts in { 17637a6dacacSDimitry Andricdefm : SIBufferAtomicPat_Common<"SIbuffer_atomic_cond_sub_u32", i32, "BUFFER_ATOMIC_COND_SUB_U32_VBUFFER", ["noret"]>; 17647a6dacacSDimitry Andric} 17657a6dacacSDimitry Andric 1766*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFMinFMaxF32GlobalInsts in { 176781ad6265SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fmin", f32, "BUFFER_ATOMIC_FMIN">; 176881ad6265SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fmax", f32, "BUFFER_ATOMIC_FMAX">; 176981ad6265SDimitry Andric} 1770*0fca6ea1SDimitry Andric 1771*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts in { 1772*0fca6ea1SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fmin", f64, "BUFFER_ATOMIC_MIN_F64">; 1773*0fca6ea1SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fmax", f64, "BUFFER_ATOMIC_MAX_F64">; 1774349cc55cSDimitry Andric} 1775349cc55cSDimitry Andric 1776e8d8bef9SDimitry Andricclass NoUseBufferAtomic<SDPatternOperator Op, ValueType vt> : PatFrag < 1777e8d8bef9SDimitry Andric (ops node:$src0, node:$src1, node:$src2, node:$src3, node:$src4, node:$src5, node:$src6, node:$src7), 1778bdd1243dSDimitry Andric (vt (Op $src0, $src1, $src2, $src3, $src4, $src5, $src6, $src7))> { 1779bdd1243dSDimitry Andric let HasNoUse = true; 1780e8d8bef9SDimitry Andric} 1781e8d8bef9SDimitry Andric 17825f757f3fSDimitry Andricmulticlass BufferAtomicPatterns_NO_RTN_Common<SDPatternOperator name, ValueType vt, 17830b57cec5SDimitry Andric string opcode> { 17840b57cec5SDimitry Andric def : GCNPat< 1785e8d8bef9SDimitry Andric (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, 0, 17865f757f3fSDimitry Andric 0, (BUFSOffset i32:$soffset), timm:$offset, 17877a6dacacSDimitry Andric timm:$auxiliary, 0), 1788e8d8bef9SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _OFFSET) getVregSrcForVT<vt>.ret:$vdata_in, SReg_128:$rsrc, SCSrc_b32:$soffset, 17897a6dacacSDimitry Andric timm:$offset, (extract_cpol $auxiliary)) 17900b57cec5SDimitry Andric >; 17910b57cec5SDimitry Andric 17920b57cec5SDimitry Andric def : GCNPat< 1793e8d8bef9SDimitry Andric (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, i32:$vindex, 17945f757f3fSDimitry Andric 0, (BUFSOffset i32:$soffset), timm:$offset, 17957a6dacacSDimitry Andric timm:$auxiliary, timm), 1796e8d8bef9SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _IDXEN) getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, 17977a6dacacSDimitry Andric timm:$offset, (extract_cpol $auxiliary)) 17980b57cec5SDimitry Andric >; 17990b57cec5SDimitry Andric 18000b57cec5SDimitry Andric def : GCNPat< 1801e8d8bef9SDimitry Andric (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, 0, 18025f757f3fSDimitry Andric i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 18037a6dacacSDimitry Andric timm:$auxiliary, 0), 1804e8d8bef9SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _OFFEN) getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, 18057a6dacacSDimitry Andric timm:$offset, (extract_cpol $auxiliary)) 18060b57cec5SDimitry Andric >; 18070b57cec5SDimitry Andric 18080b57cec5SDimitry Andric def : GCNPat< 1809e8d8bef9SDimitry Andric (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, i32:$vindex, 18105f757f3fSDimitry Andric i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 18117a6dacacSDimitry Andric timm:$auxiliary, timm), 18120b57cec5SDimitry Andric (!cast<MUBUF_Pseudo>(opcode # _BOTHEN) 1813e8d8bef9SDimitry Andric getVregSrcForVT<vt>.ret:$vdata_in, 1814e8d8bef9SDimitry Andric (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1), 18157a6dacacSDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, (extract_cpol $auxiliary)) 18160b57cec5SDimitry Andric >; 18170b57cec5SDimitry Andric} 18180b57cec5SDimitry Andric 18195f757f3fSDimitry Andricmulticlass BufferAtomicPatterns_NO_RTN<SDPatternOperator name, ValueType vt, 18205f757f3fSDimitry Andric string opcode> { 18215f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 18225f757f3fSDimitry Andric defm : BufferAtomicPatterns_NO_RTN_Common<name, vt, opcode>; 18235f757f3fSDimitry Andric } 18245f757f3fSDimitry Andric defm : BufferAtomicPatterns_NO_RTN_Common<name, vt, opcode # "_VBUFFER">; 18255f757f3fSDimitry Andric} 18265f757f3fSDimitry Andric 1827*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFaddNoRtnInsts in 1828bdd1243dSDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", f32, "BUFFER_ATOMIC_ADD_F32", ["noret"]>; 182981ad6265SDimitry Andric 1830*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicBufferGlobalPkAddF16NoRtnInsts in { 1831*0fca6ea1SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", v2f16, "BUFFER_ATOMIC_PK_ADD_F16", ["noret"]>; 1832*0fca6ea1SDimitry Andric} // End SubtargetPredicate = HasAtomicBufferGlobalPkAddF16NoRtnInsts 18337a6dacacSDimitry Andric 1834*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFaddRtnInsts in 1835bdd1243dSDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", f32, "BUFFER_ATOMIC_ADD_F32", ["ret"]>; 18360b57cec5SDimitry Andric 1837*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicBufferGlobalPkAddF16Insts in { 1838*0fca6ea1SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", v2f16, "BUFFER_ATOMIC_PK_ADD_F16", ["ret"]>; 1839*0fca6ea1SDimitry Andric} // End SubtargetPredicate = HasAtomicBufferGlobalPkAddF16Insts 18407a6dacacSDimitry Andric 1841*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasFlatBufferGlobalAtomicFaddF64Inst in { 184281ad6265SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", f64, "BUFFER_ATOMIC_ADD_F64">; 1843*0fca6ea1SDimitry Andric} // End SubtargetPredicate = HasFlatBufferGlobalAtomicFaddF64Inst 1844*0fca6ea1SDimitry Andric 1845*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts in { 184681ad6265SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fmin", f64, "BUFFER_ATOMIC_MIN_F64">; 184781ad6265SDimitry Andric defm : SIBufferAtomicPat<"SIbuffer_atomic_fmax", f64, "BUFFER_ATOMIC_MAX_F64">; 1848*0fca6ea1SDimitry Andric} //End let SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts 1849fe6060f1SDimitry Andric 18505f757f3fSDimitry Andricmulticlass SIBufferAtomicCmpSwapPat_Common<ValueType vt, ValueType data_vt, string Inst> { 185181ad6265SDimitry Andric foreach RtnMode = ["ret", "noret"] in { 1852753f127fSDimitry Andric defvar Op = !cast<SDPatternOperator>(SIbuffer_atomic_cmpswap 1853753f127fSDimitry Andric # !if(!eq(RtnMode, "ret"), "", "_noret")); 185481ad6265SDimitry Andric defvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", ""); 18557a6dacacSDimitry Andric defvar CachePolicy = !if(!eq(RtnMode, "ret"), 18567a6dacacSDimitry Andric (extract_cpol_set_glc $auxiliary), 18577a6dacacSDimitry Andric (extract_cpol $auxiliary)); 18585f757f3fSDimitry Andric defvar SrcRC = getVregSrcForVT<vt>.ret; 18597a6dacacSDimitry Andric defvar DataRC = getVregSrcForVT<data_vt>.ret.RegClass; 18605f757f3fSDimitry Andric defvar SubLo = !if(!eq(vt, i32), sub0, sub0_sub1); 18615f757f3fSDimitry Andric defvar SubHi = !if(!eq(vt, i32), sub1, sub2_sub3); 186281ad6265SDimitry Andric 18635f757f3fSDimitry Andric defvar OffsetResDag = (!cast<MUBUF_Pseudo>(Inst # "_OFFSET" # InstSuffix) 18645f757f3fSDimitry Andric (REG_SEQUENCE DataRC, SrcRC:$data, SubLo, SrcRC:$cmp, SubHi), 186506c3fb27SDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, CachePolicy); 18660b57cec5SDimitry Andric def : GCNPat< 18675f757f3fSDimitry Andric (vt (Op 18685f757f3fSDimitry Andric vt:$data, vt:$cmp, v4i32:$rsrc, 0, 0, (BUFSOffset i32:$soffset), 18697a6dacacSDimitry Andric timm:$offset, timm:$auxiliary, 0)), 187081ad6265SDimitry Andric !if(!eq(RtnMode, "ret"), 18715f757f3fSDimitry Andric (EXTRACT_SUBREG OffsetResDag, SubLo), 187281ad6265SDimitry Andric OffsetResDag) 18730b57cec5SDimitry Andric >; 18740b57cec5SDimitry Andric 18755f757f3fSDimitry Andric defvar IdxenResDag = (!cast<MUBUF_Pseudo>(Inst # "_IDXEN" # InstSuffix) 18765f757f3fSDimitry Andric (REG_SEQUENCE DataRC, SrcRC:$data, SubLo, SrcRC:$cmp, SubHi), 187706c3fb27SDimitry Andric VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 187881ad6265SDimitry Andric CachePolicy); 18790b57cec5SDimitry Andric def : GCNPat< 18805f757f3fSDimitry Andric (vt (Op 18815f757f3fSDimitry Andric vt:$data, vt:$cmp, v4i32:$rsrc, i32:$vindex, 18825f757f3fSDimitry Andric 0, (BUFSOffset i32:$soffset), timm:$offset, 18837a6dacacSDimitry Andric timm:$auxiliary, timm)), 188481ad6265SDimitry Andric !if(!eq(RtnMode, "ret"), 18855f757f3fSDimitry Andric (EXTRACT_SUBREG IdxenResDag, SubLo), 188681ad6265SDimitry Andric IdxenResDag) 18870b57cec5SDimitry Andric >; 18880b57cec5SDimitry Andric 18895f757f3fSDimitry Andric defvar OffenResDag = (!cast<MUBUF_Pseudo>(Inst # "_OFFEN" # InstSuffix) 18905f757f3fSDimitry Andric (REG_SEQUENCE DataRC, SrcRC:$data, SubLo, SrcRC:$cmp, SubHi), 189106c3fb27SDimitry Andric VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 189281ad6265SDimitry Andric CachePolicy); 18930b57cec5SDimitry Andric def : GCNPat< 18945f757f3fSDimitry Andric (vt (Op 18955f757f3fSDimitry Andric vt:$data, vt:$cmp, v4i32:$rsrc, 0, 18965f757f3fSDimitry Andric i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 18977a6dacacSDimitry Andric timm:$auxiliary, 0)), 189881ad6265SDimitry Andric !if(!eq(RtnMode, "ret"), 18995f757f3fSDimitry Andric (EXTRACT_SUBREG OffenResDag, SubLo), 190081ad6265SDimitry Andric OffenResDag) 19010b57cec5SDimitry Andric >; 19020b57cec5SDimitry Andric 19035f757f3fSDimitry Andric defvar BothenResDag = (!cast<MUBUF_Pseudo>(Inst # "_BOTHEN" # InstSuffix) 19045f757f3fSDimitry Andric (REG_SEQUENCE DataRC, SrcRC:$data, SubLo, SrcRC:$cmp, SubHi), 190581ad6265SDimitry Andric (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1), 190606c3fb27SDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, CachePolicy); 19070b57cec5SDimitry Andric def : GCNPat< 19085f757f3fSDimitry Andric (vt (Op 19095f757f3fSDimitry Andric vt:$data, vt:$cmp, v4i32:$rsrc, i32:$vindex, 19105f757f3fSDimitry Andric i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 19117a6dacacSDimitry Andric timm:$auxiliary, timm)), 191281ad6265SDimitry Andric !if(!eq(RtnMode, "ret"), 19135f757f3fSDimitry Andric (EXTRACT_SUBREG BothenResDag, SubLo), 191481ad6265SDimitry Andric BothenResDag) 19150b57cec5SDimitry Andric >; 191681ad6265SDimitry Andric } // end foreach RtnMode 19175f757f3fSDimitry Andric} 19185f757f3fSDimitry Andric 19195f757f3fSDimitry Andricmulticlass SIBufferAtomicCmpSwapPat<ValueType vt, ValueType data_vt, string Inst> { 1920*0fca6ea1SDimitry Andric let OtherPredicates = [HasUnrestrictedSOffset] in { 19215f757f3fSDimitry Andric defm : SIBufferAtomicCmpSwapPat_Common<vt, data_vt, Inst>; 19225f757f3fSDimitry Andric } 19235f757f3fSDimitry Andric defm : SIBufferAtomicCmpSwapPat_Common<vt, data_vt, Inst # "_VBUFFER">; 19245f757f3fSDimitry Andric} 19255f757f3fSDimitry Andric 19265f757f3fSDimitry Andricdefm : SIBufferAtomicCmpSwapPat<i32, v2i32, "BUFFER_ATOMIC_CMPSWAP">; 19275f757f3fSDimitry Andricdefm : SIBufferAtomicCmpSwapPat<i64, v2i64, "BUFFER_ATOMIC_CMPSWAP_X2">; 192881ad6265SDimitry Andric 19290b57cec5SDimitry Andricclass MUBUFLoad_PatternADDR64 <MUBUF_Pseudo Instr_ADDR64, ValueType vt, 19300b57cec5SDimitry Andric PatFrag constant_ld> : GCNPat < 19310b57cec5SDimitry Andric (vt (constant_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, 193206c3fb27SDimitry Andric i32:$offset))), 1933fe6060f1SDimitry Andric (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset) 19340b57cec5SDimitry Andric >; 19350b57cec5SDimitry Andric 19360b57cec5SDimitry Andricmulticlass MUBUFLoad_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET, 19370b57cec5SDimitry Andric ValueType vt, PatFrag atomic_ld> { 19380b57cec5SDimitry Andric def : GCNPat < 193906c3fb27SDimitry Andric (vt (atomic_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset))), 1940fe6060f1SDimitry Andric (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset) 19410b57cec5SDimitry Andric >; 19420b57cec5SDimitry Andric 19430b57cec5SDimitry Andric def : GCNPat < 194406c3fb27SDimitry Andric (vt (atomic_ld (MUBUFOffset v4i32:$rsrc, i32:$soffset, i32:$offset))), 1945fe6060f1SDimitry Andric (Instr_OFFSET $rsrc, $soffset, (as_i16imm $offset)) 19460b57cec5SDimitry Andric >; 19470b57cec5SDimitry Andric} 19480b57cec5SDimitry Andric 19490b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in { 19500b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SBYTE_ADDR64, i32, sextloadi8_constant>; 19510b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_UBYTE_ADDR64, i32, extloadi8_constant>; 19520b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_UBYTE_ADDR64, i32, zextloadi8_constant>; 19530b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SSHORT_ADDR64, i32, sextloadi16_constant>; 19540b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_USHORT_ADDR64, i32, extloadi16_constant>; 19550b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_USHORT_ADDR64, i32, zextloadi16_constant>; 19560b57cec5SDimitry Andric 19570b57cec5SDimitry Andricdefm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORD_ADDR64, BUFFER_LOAD_DWORD_OFFSET, i32, atomic_load_32_global>; 19580b57cec5SDimitry Andricdefm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORDX2_ADDR64, BUFFER_LOAD_DWORDX2_OFFSET, i64, atomic_load_64_global>; 19590b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7 19600b57cec5SDimitry Andric 19615f757f3fSDimitry Andricmulticlass MUBUFLoad_PatternOffset_Common <string Instr, ValueType vt, 19620b57cec5SDimitry Andric PatFrag ld> { 19630b57cec5SDimitry Andric def : GCNPat < 196406c3fb27SDimitry Andric (vt (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset))), 19655f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # "_OFFSET") $srsrc, $soffset, $offset) 19660b57cec5SDimitry Andric >; 19670b57cec5SDimitry Andric} 19680b57cec5SDimitry Andric 19695f757f3fSDimitry Andricmulticlass MUBUFLoad_PatternOffset <string Instr, ValueType vt, 19705f757f3fSDimitry Andric PatFrag ld> { 1971*0fca6ea1SDimitry Andric let OtherPredicates = [HasUnrestrictedSOffset] in { 19725f757f3fSDimitry Andric defm : MUBUFLoad_PatternOffset_Common<Instr, vt, ld>; 19735f757f3fSDimitry Andric } 19745f757f3fSDimitry Andric defm : MUBUFLoad_PatternOffset_Common<Instr # "_VBUFFER", vt, ld>; 19755f757f3fSDimitry Andric} 19765f757f3fSDimitry Andric 19770b57cec5SDimitry Andriclet OtherPredicates = [Has16BitInsts] in { 19780b57cec5SDimitry Andric 19795f757f3fSDimitry Andricdefm : MUBUFLoad_PatternOffset <"BUFFER_LOAD_SBYTE", i16, sextloadi8_constant>; 19805f757f3fSDimitry Andricdefm : MUBUFLoad_PatternOffset <"BUFFER_LOAD_UBYTE", i16, extloadi8_constant>; 19815f757f3fSDimitry Andricdefm : MUBUFLoad_PatternOffset <"BUFFER_LOAD_UBYTE", i16, zextloadi8_constant>; 19825f757f3fSDimitry Andricdefm : MUBUFLoad_PatternOffset <"BUFFER_LOAD_SBYTE", i16, sextloadi8_global>; 19835f757f3fSDimitry Andricdefm : MUBUFLoad_PatternOffset <"BUFFER_LOAD_UBYTE", i16, extloadi8_global>; 19845f757f3fSDimitry Andricdefm : MUBUFLoad_PatternOffset <"BUFFER_LOAD_UBYTE", i16, zextloadi8_global>; 19850b57cec5SDimitry Andric 19865f757f3fSDimitry Andricdefm : MUBUFLoad_PatternOffset <"BUFFER_LOAD_USHORT", i16, load_global>; 19870b57cec5SDimitry Andric 19880b57cec5SDimitry Andric} // End OtherPredicates = [Has16BitInsts] 19890b57cec5SDimitry Andric 19905f757f3fSDimitry Andricmulticlass MUBUFScratchLoadPat_Common <string Instr, 19910b57cec5SDimitry Andric ValueType vt, PatFrag ld> { 19920b57cec5SDimitry Andric def : GCNPat < 19930b57cec5SDimitry Andric (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr, 199406c3fb27SDimitry Andric i32:$soffset, i32:$offset))), 19955f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # _OFFEN) $vaddr, $srsrc, $soffset, $offset, 0, 0) 19960b57cec5SDimitry Andric >; 19970b57cec5SDimitry Andric 19980b57cec5SDimitry Andric def : GCNPat < 199906c3fb27SDimitry Andric (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, i32:$offset))), 20005f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # _OFFSET) $srsrc, $soffset, $offset, 0, 0) 20010b57cec5SDimitry Andric >; 20020b57cec5SDimitry Andric} 20030b57cec5SDimitry Andric 20045f757f3fSDimitry Andricmulticlass MUBUFScratchLoadPat <string Instr, 20055f757f3fSDimitry Andric ValueType vt, PatFrag ld> { 20065f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 20075f757f3fSDimitry Andric defm : MUBUFScratchLoadPat_Common<Instr, vt, ld>; 20085f757f3fSDimitry Andric } 20095f757f3fSDimitry Andric defm : MUBUFScratchLoadPat_Common<Instr # "_VBUFFER", vt, ld>; 20105f757f3fSDimitry Andric} 20115f757f3fSDimitry Andric 20120b57cec5SDimitry Andric// XXX - Is it possible to have a complex pattern in a PatFrag? 20135f757f3fSDimitry Andricmulticlass MUBUFScratchLoadPat_D16_Common <string Instr, 20140b57cec5SDimitry Andric ValueType vt, PatFrag ld_frag> { 20150b57cec5SDimitry Andric def : GCNPat < 201606c3fb27SDimitry Andric (ld_frag (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr, i32:$soffset, i32:$offset), vt:$in), 20175f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # _OFFEN) $vaddr, $srsrc, $soffset, $offset, $in) 20180b57cec5SDimitry Andric >; 20190b57cec5SDimitry Andric 20200b57cec5SDimitry Andric def : GCNPat < 202106c3fb27SDimitry Andric (ld_frag (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, i32:$offset), vt:$in), 20225f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # _OFFSET) $srsrc, $soffset, $offset, $in) 20230b57cec5SDimitry Andric >; 20240b57cec5SDimitry Andric} 20250b57cec5SDimitry Andric 20265f757f3fSDimitry Andricmulticlass MUBUFScratchLoadPat_D16 <string Instr, 20275f757f3fSDimitry Andric ValueType vt, PatFrag ld_frag> { 20285f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 20295f757f3fSDimitry Andric defm : MUBUFScratchLoadPat_D16_Common<Instr, vt, ld_frag>; 20305f757f3fSDimitry Andric } 20315f757f3fSDimitry Andric defm : MUBUFScratchLoadPat_D16_Common<Instr # "_VBUFFER", vt, ld_frag>; 20325f757f3fSDimitry Andric} 20335f757f3fSDimitry Andric 2034e8d8bef9SDimitry Andriclet OtherPredicates = [DisableFlatScratch] in { 20355f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_SBYTE", i32, sextloadi8_private>; 20365f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_UBYTE", i32, extloadi8_private>; 20375f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_UBYTE", i32, zextloadi8_private>; 20385f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_SBYTE", i16, sextloadi8_private>; 20395f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_UBYTE", i16, extloadi8_private>; 20405f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_UBYTE", i16, zextloadi8_private>; 20415f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_SSHORT", i32, sextloadi16_private>; 20425f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_USHORT", i32, extloadi16_private>; 20435f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_USHORT", i32, zextloadi16_private>; 20445f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_USHORT", i16, load_private>; 20458bcb0991SDimitry Andric 20468bcb0991SDimitry Andricforeach vt = Reg32Types.types in { 20475f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_DWORD", vt, load_private>; 20488bcb0991SDimitry Andric} 20495f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_DWORDX2", v2i32, load_private>; 20505f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_DWORDX3", v3i32, load_private>; 20515f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat <"BUFFER_LOAD_DWORDX4", v4i32, load_private>; 20520b57cec5SDimitry Andric 2053e8d8bef9SDimitry Andriclet OtherPredicates = [D16PreservesUnusedBits, DisableFlatScratch] in { 20545f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SHORT_D16_HI", v2i16, load_d16_hi_private>; 20555f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_UBYTE_D16_HI", v2i16, az_extloadi8_d16_hi_private>; 20565f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SBYTE_D16_HI", v2i16, sextloadi8_d16_hi_private>; 20575f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SHORT_D16_HI", v2f16, load_d16_hi_private>; 20585f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_UBYTE_D16_HI", v2f16, az_extloadi8_d16_hi_private>; 20595f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SBYTE_D16_HI", v2f16, sextloadi8_d16_hi_private>; 20600b57cec5SDimitry Andric 20615f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SHORT_D16", v2i16, load_d16_lo_private>; 20625f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_UBYTE_D16", v2i16, az_extloadi8_d16_lo_private>; 20635f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SBYTE_D16", v2i16, sextloadi8_d16_lo_private>; 20645f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SHORT_D16", v2f16, load_d16_lo_private>; 20655f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_UBYTE_D16", v2f16, az_extloadi8_d16_lo_private>; 20665f757f3fSDimitry Andricdefm : MUBUFScratchLoadPat_D16<"BUFFER_LOAD_SBYTE_D16", v2f16, sextloadi8_d16_lo_private>; 20670b57cec5SDimitry Andric} 20680b57cec5SDimitry Andric 2069e8d8bef9SDimitry Andric} // End OtherPredicates = [DisableFlatScratch] 2070e8d8bef9SDimitry Andric 20710b57cec5SDimitry Andricmulticlass MUBUFStore_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET, 20720b57cec5SDimitry Andric ValueType vt, PatFrag atomic_st> { 20730b57cec5SDimitry Andric def : GCNPat < 20745f757f3fSDimitry Andric (atomic_st vt:$val, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset)), 2075fe6060f1SDimitry Andric (Instr_ADDR64 $val, $vaddr, $srsrc, $soffset, $offset) 20760b57cec5SDimitry Andric >; 20770b57cec5SDimitry Andric 20780b57cec5SDimitry Andric def : GCNPat < 20795f757f3fSDimitry Andric (atomic_st vt:$val, (MUBUFOffset v4i32:$rsrc, i32:$soffset, i32:$offset)), 2080fe6060f1SDimitry Andric (Instr_OFFSET $val, $rsrc, $soffset, (as_i16imm $offset)) 20810b57cec5SDimitry Andric >; 20820b57cec5SDimitry Andric} 20830b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in { 208481ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_BYTE_ADDR64, BUFFER_STORE_BYTE_OFFSET, i32, atomic_store_8_global>; 208581ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_BYTE_ADDR64, BUFFER_STORE_BYTE_OFFSET, i16, atomic_store_8_global>; 208681ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_SHORT_ADDR64, BUFFER_STORE_SHORT_OFFSET, i32, atomic_store_16_global>; 208781ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_SHORT_ADDR64, BUFFER_STORE_SHORT_OFFSET, i16, atomic_store_16_global>; 208881ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORD_ADDR64, BUFFER_STORE_DWORD_OFFSET, i32, atomic_store_32_global>; 208981ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORDX2_ADDR64, BUFFER_STORE_DWORDX2_OFFSET, i64, atomic_store_64_global>; 20900b57cec5SDimitry Andric} // End Predicates = isGFX6GFX7 20910b57cec5SDimitry Andric 20920b57cec5SDimitry Andric 20935f757f3fSDimitry Andricmulticlass MUBUFStore_PatternOffset_Common <string Instr, ValueType vt, 20940b57cec5SDimitry Andric PatFrag st> { 20950b57cec5SDimitry Andric 20960b57cec5SDimitry Andric def : GCNPat < 209706c3fb27SDimitry Andric (st vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset)), 20985f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # "_OFFSET") $vdata, $srsrc, $soffset, $offset) 20990b57cec5SDimitry Andric >; 21000b57cec5SDimitry Andric} 21010b57cec5SDimitry Andric 21025f757f3fSDimitry Andricmulticlass MUBUFStore_PatternOffset <string Instr, ValueType vt, 21035f757f3fSDimitry Andric PatFrag st> { 21045f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 21055f757f3fSDimitry Andric defm : MUBUFStore_PatternOffset_Common<Instr, vt, st>; 21065f757f3fSDimitry Andric } 21075f757f3fSDimitry Andric defm : MUBUFStore_PatternOffset_Common<Instr # "_VBUFFER", vt, st>; 21085f757f3fSDimitry Andric} 21090b57cec5SDimitry Andric 21105f757f3fSDimitry Andricdefm : MUBUFStore_PatternOffset <"BUFFER_STORE_BYTE", i16, truncstorei8_global>; 21115f757f3fSDimitry Andricdefm : MUBUFStore_PatternOffset <"BUFFER_STORE_SHORT", i16, store_global>; 21125f757f3fSDimitry Andric 21135f757f3fSDimitry Andricmulticlass MUBUFScratchStorePat_Common <string Instr, 21140b57cec5SDimitry Andric ValueType vt, PatFrag st, 21150b57cec5SDimitry Andric RegisterClass rc = VGPR_32> { 21160b57cec5SDimitry Andric def : GCNPat < 21170b57cec5SDimitry Andric (st vt:$value, (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr, 211806c3fb27SDimitry Andric i32:$soffset, i32:$offset)), 21195f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # _OFFEN) rc:$value, $vaddr, $srsrc, $soffset, $offset, 0, 0) 21200b57cec5SDimitry Andric >; 21210b57cec5SDimitry Andric 21220b57cec5SDimitry Andric def : GCNPat < 21230b57cec5SDimitry Andric (st vt:$value, (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, 212406c3fb27SDimitry Andric i32:$offset)), 21255f757f3fSDimitry Andric (!cast<MUBUF_Pseudo>(Instr # _OFFSET) rc:$value, $srsrc, $soffset, $offset, 0, 0) 21260b57cec5SDimitry Andric >; 21270b57cec5SDimitry Andric} 21280b57cec5SDimitry Andric 21295f757f3fSDimitry Andricmulticlass MUBUFScratchStorePat <string Instr, 21305f757f3fSDimitry Andric ValueType vt, PatFrag st, 21315f757f3fSDimitry Andric RegisterClass rc = VGPR_32> { 21325f757f3fSDimitry Andric let SubtargetPredicate = HasUnrestrictedSOffset in { 21335f757f3fSDimitry Andric defm : MUBUFScratchStorePat_Common<Instr, vt, st, rc>; 21345f757f3fSDimitry Andric } 21355f757f3fSDimitry Andric defm : MUBUFScratchStorePat_Common<Instr # "_VBUFFER", vt, st, rc>; 21368bcb0991SDimitry Andric} 21378bcb0991SDimitry Andric 21385f757f3fSDimitry Andriclet OtherPredicates = [DisableFlatScratch] in { 21395f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_BYTE", i32, truncstorei8_private>; 21405f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_SHORT", i32, truncstorei16_private>; 21415f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_BYTE", i16, truncstorei8_private>; 21425f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_SHORT", i16, store_private>; 21435f757f3fSDimitry Andric 21445f757f3fSDimitry Andricforeach vt = Reg32Types.types in { 21455f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_DWORD", vt, store_private>; 21465f757f3fSDimitry Andric} 21475f757f3fSDimitry Andric 21485f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_DWORDX2", v2i32, store_private, VReg_64>; 21495f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_DWORDX3", v3i32, store_private, VReg_96>; 21505f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_DWORDX4", v4i32, store_private, VReg_128>; 21510b57cec5SDimitry Andric 21520b57cec5SDimitry Andric 215381ad6265SDimitry Andriclet OtherPredicates = [HasD16LoadStore, DisableFlatScratch] in { 21540b57cec5SDimitry Andric // Hiding the extract high pattern in the PatFrag seems to not 21550b57cec5SDimitry Andric // automatically increase the complexity. 21560b57cec5SDimitry Andriclet AddedComplexity = 1 in { 21575f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_SHORT_D16_HI", i32, store_hi16_private>; 21585f757f3fSDimitry Andricdefm : MUBUFScratchStorePat <"BUFFER_STORE_BYTE_D16_HI", i32, truncstorei8_hi16_private>; 21590b57cec5SDimitry Andric} 21600b57cec5SDimitry Andric} 2161e8d8bef9SDimitry Andric} // End OtherPredicates = [DisableFlatScratch] 21620b57cec5SDimitry Andric 21630b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 21640b57cec5SDimitry Andric// MTBUF Patterns 21650b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 21660b57cec5SDimitry Andric 21670b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 21680b57cec5SDimitry Andric// tbuffer_load/store_format patterns 21690b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 21700b57cec5SDimitry Andric 21715f757f3fSDimitry Andricmulticlass MTBUF_LoadIntrinsicPat_Common<SDPatternOperator name, ValueType vt, 2172e8d8bef9SDimitry Andric string opcode, ValueType memoryVt = vt> { 2173fe6060f1SDimitry Andric defvar st = !if(!eq(memoryVt, vt), name, mtbuf_intrinsic_load<name, memoryVt>); 2174e8d8bef9SDimitry Andric 21750b57cec5SDimitry Andric def : GCNPat< 21765f757f3fSDimitry Andric (vt (st v4i32:$rsrc, 0, 0, (BUFSOffset i32:$soffset), timm:$offset, 21778bcb0991SDimitry Andric timm:$format, timm:$auxiliary, 0)), 217806c3fb27SDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _OFFSET) SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 21795ffd83dbSDimitry Andric (as_i8timm $format), 2180bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 21810b57cec5SDimitry Andric >; 21820b57cec5SDimitry Andric 21830b57cec5SDimitry Andric def : GCNPat< 21845f757f3fSDimitry Andric (vt (st v4i32:$rsrc, i32:$vindex, 0, (BUFSOffset i32:$soffset), timm:$offset, 21858bcb0991SDimitry Andric timm:$format, timm:$auxiliary, timm)), 218606c3fb27SDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _IDXEN) VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 21875ffd83dbSDimitry Andric (as_i8timm $format), 2188bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 21890b57cec5SDimitry Andric >; 21900b57cec5SDimitry Andric 21910b57cec5SDimitry Andric def : GCNPat< 21925f757f3fSDimitry Andric (vt (st v4i32:$rsrc, 0, i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 21938bcb0991SDimitry Andric timm:$format, timm:$auxiliary, 0)), 219406c3fb27SDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _OFFEN) VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 21955ffd83dbSDimitry Andric (as_i8timm $format), 2196bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 21970b57cec5SDimitry Andric >; 21980b57cec5SDimitry Andric 21990b57cec5SDimitry Andric def : GCNPat< 22005f757f3fSDimitry Andric (vt (st v4i32:$rsrc, i32:$vindex, i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 22018bcb0991SDimitry Andric timm:$format, timm:$auxiliary, timm)), 22020b57cec5SDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _BOTHEN) 22035ffd83dbSDimitry Andric (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1), 220406c3fb27SDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, 22055ffd83dbSDimitry Andric (as_i8timm $format), 2206bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 22070b57cec5SDimitry Andric >; 22080b57cec5SDimitry Andric} 22090b57cec5SDimitry Andric 22105f757f3fSDimitry Andricmulticlass MTBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt, 22115f757f3fSDimitry Andric string opcode, ValueType memoryVt = vt> { 2212*0fca6ea1SDimitry Andric let OtherPredicates = [HasUnrestrictedSOffset] in { 22135f757f3fSDimitry Andric defm : MTBUF_LoadIntrinsicPat_Common<name, vt, opcode, memoryVt>; 22145f757f3fSDimitry Andric } 22155f757f3fSDimitry Andric defm : MTBUF_LoadIntrinsicPat_Common<name, vt, opcode # "_VBUFFER", memoryVt>; 22165f757f3fSDimitry Andric} 22175f757f3fSDimitry Andric 22180b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, i32, "TBUFFER_LOAD_FORMAT_X">; 22190b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2i32, "TBUFFER_LOAD_FORMAT_XY">; 22200b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v3i32, "TBUFFER_LOAD_FORMAT_XYZ">; 22210b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4i32, "TBUFFER_LOAD_FORMAT_XYZW">; 22220b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, f32, "TBUFFER_LOAD_FORMAT_X">; 22230b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2f32, "TBUFFER_LOAD_FORMAT_XY">; 22240b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v3f32, "TBUFFER_LOAD_FORMAT_XYZ">; 22250b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4f32, "TBUFFER_LOAD_FORMAT_XYZW">; 22260b57cec5SDimitry Andric 2227*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in { 22285f757f3fSDimitry Andric defm : MTBUF_LoadIntrinsicPat_Common<SItbuffer_load_d16, f16, "TBUFFER_LOAD_FORMAT_D16_X_gfx80">; 22295f757f3fSDimitry Andric defm : MTBUF_LoadIntrinsicPat_Common<SItbuffer_load_d16, i32, "TBUFFER_LOAD_FORMAT_D16_X_gfx80">; 22305f757f3fSDimitry Andric defm : MTBUF_LoadIntrinsicPat_Common<SItbuffer_load_d16, v2i32, "TBUFFER_LOAD_FORMAT_D16_XY_gfx80">; 22315f757f3fSDimitry Andric defm : MTBUF_LoadIntrinsicPat_Common<SItbuffer_load_d16, v3i32, "TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80">; 22325f757f3fSDimitry Andric defm : MTBUF_LoadIntrinsicPat_Common<SItbuffer_load_d16, v4i32, "TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80">; 22330b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 22340b57cec5SDimitry Andric 2235*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in { 22360b57cec5SDimitry Andric defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, f16, "TBUFFER_LOAD_FORMAT_D16_X">; 22375ffd83dbSDimitry Andric defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, i32, "TBUFFER_LOAD_FORMAT_D16_X">; 22380b57cec5SDimitry Andric defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v2f16, "TBUFFER_LOAD_FORMAT_D16_XY">; 2239e8d8bef9SDimitry Andric defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4f16, "TBUFFER_LOAD_FORMAT_D16_XYZ", v3f16>; 22400b57cec5SDimitry Andric defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4f16, "TBUFFER_LOAD_FORMAT_D16_XYZW">; 22410b57cec5SDimitry Andric} // End HasPackedD16VMem. 22420b57cec5SDimitry Andric 22435f757f3fSDimitry Andricmulticlass MTBUF_StoreIntrinsicPat_Common<SDPatternOperator name, ValueType vt, 2244e8d8bef9SDimitry Andric string opcode, ValueType memoryVt = vt> { 2245fe6060f1SDimitry Andric defvar st = !if(!eq(memoryVt, vt), name, mtbuf_intrinsic_store<name, memoryVt>); 2246e8d8bef9SDimitry Andric 22470b57cec5SDimitry Andric def : GCNPat< 22485f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, 0, 0, (BUFSOffset i32:$soffset), timm:$offset, 22498bcb0991SDimitry Andric timm:$format, timm:$auxiliary, 0), 22505ffd83dbSDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _OFFSET_exact) getVregSrcForVT<vt>.ret:$vdata, SReg_128:$rsrc, SCSrc_b32:$soffset, 225106c3fb27SDimitry Andric timm:$offset, (as_i8timm $format), 2252bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 22530b57cec5SDimitry Andric >; 22540b57cec5SDimitry Andric 22550b57cec5SDimitry Andric def : GCNPat< 22565f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, (BUFSOffset i32:$soffset), timm:$offset, 22578bcb0991SDimitry Andric timm:$format, timm:$auxiliary, timm), 22585ffd83dbSDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _IDXEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, 225906c3fb27SDimitry Andric timm:$offset, (as_i8timm $format), 2260bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 22610b57cec5SDimitry Andric >; 22620b57cec5SDimitry Andric 22630b57cec5SDimitry Andric def : GCNPat< 22645f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, (BUFSOffset i32:$soffset), timm:$offset, 22658bcb0991SDimitry Andric timm:$format, timm:$auxiliary, 0), 22665ffd83dbSDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _OFFEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, 226706c3fb27SDimitry Andric timm:$offset, (as_i8timm $format), 2268bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 22690b57cec5SDimitry Andric >; 22700b57cec5SDimitry Andric 22710b57cec5SDimitry Andric def : GCNPat< 22725f757f3fSDimitry Andric (st vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, (BUFSOffset i32:$soffset), 22738bcb0991SDimitry Andric timm:$offset, timm:$format, timm:$auxiliary, timm), 22740b57cec5SDimitry Andric (!cast<MTBUF_Pseudo>(opcode # _BOTHEN_exact) 22755ffd83dbSDimitry Andric getVregSrcForVT<vt>.ret:$vdata, 22765ffd83dbSDimitry Andric (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1), 227706c3fb27SDimitry Andric SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, (as_i8timm $format), 2278bdd1243dSDimitry Andric (extract_cpol $auxiliary), (extract_swz $auxiliary)) 22790b57cec5SDimitry Andric >; 22800b57cec5SDimitry Andric} 22810b57cec5SDimitry Andric 22825f757f3fSDimitry Andricmulticlass MTBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt, 22835f757f3fSDimitry Andric string opcode, ValueType memoryVt = vt> { 2284*0fca6ea1SDimitry Andric let OtherPredicates = [HasUnrestrictedSOffset] in { 22855f757f3fSDimitry Andric defm : MTBUF_StoreIntrinsicPat_Common<name, vt, opcode, memoryVt>; 22865f757f3fSDimitry Andric } 22875f757f3fSDimitry Andric defm : MTBUF_StoreIntrinsicPat_Common<name, vt, opcode # "_VBUFFER", memoryVt>; 22885f757f3fSDimitry Andric} 22895f757f3fSDimitry Andric 22900b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, i32, "TBUFFER_STORE_FORMAT_X">; 22910b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2i32, "TBUFFER_STORE_FORMAT_XY">; 22920b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v3i32, "TBUFFER_STORE_FORMAT_XYZ">; 22930b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4i32, "TBUFFER_STORE_FORMAT_XYZW">; 22940b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, f32, "TBUFFER_STORE_FORMAT_X">; 22950b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2f32, "TBUFFER_STORE_FORMAT_XY">; 22960b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v3f32, "TBUFFER_STORE_FORMAT_XYZ">; 22970b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4f32, "TBUFFER_STORE_FORMAT_XYZW">; 22980b57cec5SDimitry Andric 2299*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in { 23005f757f3fSDimitry Andric defm : MTBUF_StoreIntrinsicPat_Common<SItbuffer_store_d16, f16, "TBUFFER_STORE_FORMAT_D16_X_gfx80">; 23015f757f3fSDimitry Andric defm : MTBUF_StoreIntrinsicPat_Common<SItbuffer_store_d16, i32, "TBUFFER_STORE_FORMAT_D16_X_gfx80">; 23025f757f3fSDimitry Andric defm : MTBUF_StoreIntrinsicPat_Common<SItbuffer_store_d16, v2i32, "TBUFFER_STORE_FORMAT_D16_XY_gfx80">; 23035f757f3fSDimitry Andric defm : MTBUF_StoreIntrinsicPat_Common<SItbuffer_store_d16, v3i32, "TBUFFER_STORE_FORMAT_D16_XYZ_gfx80">; 23045f757f3fSDimitry Andric defm : MTBUF_StoreIntrinsicPat_Common<SItbuffer_store_d16, v4i32, "TBUFFER_STORE_FORMAT_D16_XYZW_gfx80">; 23050b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 23060b57cec5SDimitry Andric 2307*0fca6ea1SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in { 23080b57cec5SDimitry Andric defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, f16, "TBUFFER_STORE_FORMAT_D16_X">; 23095ffd83dbSDimitry Andric defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, i32, "TBUFFER_STORE_FORMAT_D16_X">; 23100b57cec5SDimitry Andric defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v2f16, "TBUFFER_STORE_FORMAT_D16_XY">; 2311e8d8bef9SDimitry Andric defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4f16, "TBUFFER_STORE_FORMAT_D16_XYZ", v3f16>; 23120b57cec5SDimitry Andric defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4f16, "TBUFFER_STORE_FORMAT_D16_XYZW">; 23130b57cec5SDimitry Andric} // End HasPackedD16VMem. 23140b57cec5SDimitry Andric 23150b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 23160b57cec5SDimitry Andric// Target-specific instruction encodings. 23170b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 23180b57cec5SDimitry Andric 2319*0fca6ea1SDimitry Andric// Shortcut to default Mnemonic from BUF_Pseudo. Hides the cast to the 2320*0fca6ea1SDimitry Andric// specific pseudo (bothen in this case) since any of them will work. 2321*0fca6ea1SDimitry Andricclass get_BUF_ps<string name> { 2322*0fca6ea1SDimitry Andric string Mnemonic = !cast<BUF_Pseudo>(name # "_OFFSET").Mnemonic; 2323*0fca6ea1SDimitry Andric} 2324*0fca6ea1SDimitry Andric 23250b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 232681ad6265SDimitry Andric// Base ENC_MUBUF for GFX6, GFX7, GFX10, GFX11. 23270b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 23280b57cec5SDimitry Andric 232981ad6265SDimitry Andricclass Base_MUBUF_Real_gfx6_gfx7_gfx10_gfx11 <MUBUF_Pseudo ps, int ef, 233081ad6265SDimitry Andric string real_name = ps.Mnemonic> : 233181ad6265SDimitry Andric MUBUF_Real<ps, real_name>, Enc64, SIMCInstr<ps.PseudoInstr, ef> { 23320b57cec5SDimitry Andric let Inst{11-0} = !if(ps.has_offset, offset, ?); 233381ad6265SDimitry Andric let Inst{31-26} = 0x38; 233481ad6265SDimitry Andric let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?); 233581ad6265SDimitry Andric let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?); 233681ad6265SDimitry Andric let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?); 233781ad6265SDimitry Andric let Inst{63-56} = !if(ps.has_soffset, soffset, ?); 233881ad6265SDimitry Andric} 233981ad6265SDimitry Andric 2340*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_gfx11<bits<8> op, string real_name = !cast<MUBUF_Pseudo>(NAME).Mnemonic> { 2341*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 2342*0fca6ea1SDimitry Andric def _gfx11 : Base_MUBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, SIEncodingFamily.GFX11, real_name> { 234381ad6265SDimitry Andric let Inst{12} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 2344*0fca6ea1SDimitry Andric // In GFX11 dlc is applicable to all loads/stores/atomics. 2345*0fca6ea1SDimitry Andric let Inst{13} = !if(!or(ps.mayLoad, ps.mayStore), cpol{CPolBit.DLC}, ps.dlc_value); 234681ad6265SDimitry Andric let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value); 234781ad6265SDimitry Andric let Inst{25-18} = op; 2348bdd1243dSDimitry Andric let Inst{53} = ps.tfe; 234981ad6265SDimitry Andric let Inst{54} = ps.offen; 235081ad6265SDimitry Andric let Inst{55} = ps.idxen; 2351*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX11Only; 2352*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX11"; 2353*0fca6ea1SDimitry Andric } 235481ad6265SDimitry Andric} 235581ad6265SDimitry Andric 2356*0fca6ea1SDimitry Andricclass Base_MUBUF_Real_gfx6_gfx7_gfx10<bits<7> op, MUBUF_Pseudo ps, int ef, string asmName> : 2357*0fca6ea1SDimitry Andric Base_MUBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, ef, asmName> { 23580b57cec5SDimitry Andric let Inst{12} = ps.offen; 23590b57cec5SDimitry Andric let Inst{13} = ps.idxen; 2360fe6060f1SDimitry Andric let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value); 2361e8d8bef9SDimitry Andric let Inst{16} = ps.lds; 23620b57cec5SDimitry Andric let Inst{24-18} = op; 2363fe6060f1SDimitry Andric let Inst{54} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 2364bdd1243dSDimitry Andric let Inst{55} = ps.tfe; 23650b57cec5SDimitry Andric} 23660b57cec5SDimitry Andric 2367*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_gfx10<bits<8> op, string psName = NAME, 2368*0fca6ea1SDimitry Andric string asmName = !cast<MUBUF_Pseudo>(psName).Mnemonic> { 2369*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(psName); 2370*0fca6ea1SDimitry Andric def _gfx10 : Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.GFX10, asmName> { 2371fe6060f1SDimitry Andric let Inst{15} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlc_value); 23720b57cec5SDimitry Andric let Inst{25} = op{7}; 2373*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX10Only; 2374*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX10"; 2375*0fca6ea1SDimitry Andric } 23760b57cec5SDimitry Andric} 23770b57cec5SDimitry Andric 2378*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_gfx6_gfx7<bits<8> op, string psName = NAME, 2379*0fca6ea1SDimitry Andric string asmName = !cast<MUBUF_Pseudo>(psName).Mnemonic> { 2380*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(psName); 2381*0fca6ea1SDimitry Andric def _gfx6_gfx7 : Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.SI, asmName> { 23820b57cec5SDimitry Andric let Inst{15} = ps.addr64; 2383*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX6GFX7; 2384*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX6GFX7"; 2385*0fca6ea1SDimitry Andric } 2386*0fca6ea1SDimitry Andric} 2387*0fca6ea1SDimitry Andric 2388*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_gfx6<bits<8> op> { 2389*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 2390*0fca6ea1SDimitry Andric def _gfx6 : Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.SI, ps.Mnemonic> { 2391*0fca6ea1SDimitry Andric let Inst{15} = ps.addr64; 2392*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX6; 2393*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX6"; 2394*0fca6ea1SDimitry Andric } 2395*0fca6ea1SDimitry Andric} 2396*0fca6ea1SDimitry Andric 2397*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_gfx7<bits<8> op> { 2398*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 2399*0fca6ea1SDimitry Andric def _gfx7 : Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.SI, ps.Mnemonic> { 2400*0fca6ea1SDimitry Andric let Inst{15} = ps.addr64; 2401*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX7Only; 2402*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX7"; 2403*0fca6ea1SDimitry Andric } 24040b57cec5SDimitry Andric} 24050b57cec5SDimitry Andric 24060b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 24075f757f3fSDimitry Andric// Base ENC_VBUFFER for GFX12. 24085f757f3fSDimitry Andric//===----------------------------------------------------------------------===// 24095f757f3fSDimitry Andric 2410*0fca6ea1SDimitry Andricclass VBUFFER_Real <bits<8> op, BUF_Pseudo ps, string real_name> : 24115f757f3fSDimitry Andric InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []>, Enc96 { 24125f757f3fSDimitry Andric 24135f757f3fSDimitry Andric let isPseudo = 0; 24145f757f3fSDimitry Andric let isCodeGenOnly = 0; 24155f757f3fSDimitry Andric 24165f757f3fSDimitry Andric let VM_CNT = 1; 24175f757f3fSDimitry Andric let EXP_CNT = 1; 24185f757f3fSDimitry Andric 24195f757f3fSDimitry Andric // copy relevant pseudo op flags 24205f757f3fSDimitry Andric let SubtargetPredicate = ps.SubtargetPredicate; 24215f757f3fSDimitry Andric let AsmMatchConverter = ps.AsmMatchConverter; 24225f757f3fSDimitry Andric let OtherPredicates = ps.OtherPredicates; 24235f757f3fSDimitry Andric let Constraints = ps.Constraints; 24245f757f3fSDimitry Andric let DisableEncoding = ps.DisableEncoding; 24255f757f3fSDimitry Andric let TSFlags = ps.TSFlags; 24265f757f3fSDimitry Andric let UseNamedOperandTable = ps.UseNamedOperandTable; 24275f757f3fSDimitry Andric let SchedRW = ps.SchedRW; 24285f757f3fSDimitry Andric let mayLoad = ps.mayLoad; 24295f757f3fSDimitry Andric let mayStore = ps.mayStore; 24305f757f3fSDimitry Andric let IsAtomicRet = ps.IsAtomicRet; 24315f757f3fSDimitry Andric let IsAtomicNoRet = ps.IsAtomicNoRet; 24325f757f3fSDimitry Andric let VALU = ps.VALU; 24335f757f3fSDimitry Andric let LGKM_CNT = ps.LGKM_CNT; 2434*0fca6ea1SDimitry Andric let MUBUF = ps.MUBUF; 2435*0fca6ea1SDimitry Andric let MTBUF = ps.MTBUF; 2436*0fca6ea1SDimitry Andric let Uses = ps.Uses; 2437*0fca6ea1SDimitry Andric let Defs = ps.Defs; 24385f757f3fSDimitry Andric 24395f757f3fSDimitry Andric bits<24> offset; 24405f757f3fSDimitry Andric bits<8> vaddr; 24415f757f3fSDimitry Andric bits<10> vdata; 24425f757f3fSDimitry Andric 24435f757f3fSDimitry Andric bits<7> srsrc; 24445f757f3fSDimitry Andric bits<7> soffset; 24455f757f3fSDimitry Andric bits<6> cpol; 24465f757f3fSDimitry Andric 24475f757f3fSDimitry Andric let Inst{95-72} = !if(ps.has_offset, offset, ?); 24485f757f3fSDimitry Andric let Inst{71-64} = !if(ps.has_vaddr, vaddr, ?); 24495f757f3fSDimitry Andric let Inst{39-32} = !if(ps.has_vdata, vdata{7-0}, ?); 24505f757f3fSDimitry Andric 24515f757f3fSDimitry Andric let Inst{47-41} = !if(ps.has_srsrc, srsrc, ?); 24525f757f3fSDimitry Andric let Inst{49-48} = 0b00; 24535f757f3fSDimitry Andric let Inst{6-0} = !if(ps.has_soffset, soffset, ?); 2454*0fca6ea1SDimitry Andric let Inst{21-14} = op; 24555f757f3fSDimitry Andric let Inst{22} = ps.tfe; 24565f757f3fSDimitry Andric let Inst{62} = ps.offen; 24575f757f3fSDimitry Andric let Inst{63} = ps.idxen; 24585f757f3fSDimitry Andric 24595f757f3fSDimitry Andric let Inst{54-53} = cpol{2-1}; // th{2-1} 24605f757f3fSDimitry Andric let Inst{52} = !if(ps.IsAtomicRet, 1, cpol{0}); // th{0} 24615f757f3fSDimitry Andric let Inst{51-50} = cpol{4-3}; // scope 24625f757f3fSDimitry Andric 24635f757f3fSDimitry Andric let Inst{31-26} = 0b110001; 24645f757f3fSDimitry Andric} 24655f757f3fSDimitry Andric 2466*0fca6ea1SDimitry Andricclass VBUFFER_Real_gfx12<bits<8> op, BUF_Pseudo ps, string real_name> : 2467*0fca6ea1SDimitry Andric VBUFFER_Real<op, ps, real_name>, 2468*0fca6ea1SDimitry Andric SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX12> { 2469*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX12Only; 2470*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX12"; 24715f757f3fSDimitry Andric} 24725f757f3fSDimitry Andric 2473*0fca6ea1SDimitry Andricmulticlass VBUFFER_MUBUF_Real_gfx12<bits<8> op, string real_name> { 2474*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 2475*0fca6ea1SDimitry Andric def _gfx12 : VBUFFER_Real_gfx12<op, ps, real_name> { 2476*0fca6ea1SDimitry Andric // Set the format field to be 1 to avoid round-trip issues, as some tools 2477*0fca6ea1SDimitry Andric // print BUF_FMT_INVALID for format 0. 2478*0fca6ea1SDimitry Andric let Inst{61-55} = 0b0000001; 2479*0fca6ea1SDimitry Andric } 2480*0fca6ea1SDimitry Andric // Have a version of the instruction to disassemble to for any other 2481*0fca6ea1SDimitry Andric // format field values. 2482*0fca6ea1SDimitry Andric def _gfx12_format : VBUFFER_Real<op, ps, real_name> { 2483*0fca6ea1SDimitry Andric let AsmVariantName = "NonParsable"; 2484*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX12"; 2485*0fca6ea1SDimitry Andric } 2486*0fca6ea1SDimitry Andric} 24875f757f3fSDimitry Andric 2488*0fca6ea1SDimitry Andricmulticlass VBUFFER_MTBUF_Real_gfx12<bits<4> op, string real_name> { 2489*0fca6ea1SDimitry Andric defvar ps = !cast<MTBUF_Pseudo>(NAME); 2490*0fca6ea1SDimitry Andric def _gfx12 : VBUFFER_Real_gfx12<{0b1000, op}, ps, real_name> { 24915f757f3fSDimitry Andric bits<7> format; 24925f757f3fSDimitry Andric let Inst{61-55} = format; 24935f757f3fSDimitry Andric } 2494*0fca6ea1SDimitry Andric} 24955f757f3fSDimitry Andric 24965f757f3fSDimitry Andric//===----------------------------------------------------------------------===// 24975f757f3fSDimitry Andric// MUBUF - GFX11, GFX12. 249881ad6265SDimitry Andric//===----------------------------------------------------------------------===// 249981ad6265SDimitry Andric 2500bdd1243dSDimitry Andric// gfx11 instruction that accept both old and new assembler name. 25015f757f3fSDimitry Andricclass Mnem_gfx11_gfx12 <string mnemonic, string real_name> : 2502*0fca6ea1SDimitry Andric AMDGPUMnemonicAlias<mnemonic, real_name> { 2503*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX11Plus; 2504*0fca6ea1SDimitry Andric} 250581ad6265SDimitry Andric 25065f757f3fSDimitry Andricclass Mnem_gfx11 <string mnemonic, string real_name> : 2507*0fca6ea1SDimitry Andric AMDGPUMnemonicAlias<mnemonic, real_name> { 2508*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX11Only; 2509*0fca6ea1SDimitry Andric} 25105f757f3fSDimitry Andric 25115f757f3fSDimitry Andricclass Mnem_gfx12 <string mnemonic, string real_name> : 2512*0fca6ea1SDimitry Andric AMDGPUMnemonicAlias<mnemonic, real_name> { 2513*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX12Plus; 25145f757f3fSDimitry Andric} 25155f757f3fSDimitry Andric 2516*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_Impl2<bits<8> op, string real_name> { 2517*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx11<op, real_name>; 2518*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx11<op, real_name>; 2519*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx11<op, real_name>; 2520*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx11<op, real_name>; 25215f757f3fSDimitry Andric} 25225f757f3fSDimitry Andric 2523*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx12_Impl2<bits<8> op, string real_name> { 2524*0fca6ea1SDimitry Andric defm _VBUFFER_BOTHEN : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 2525*0fca6ea1SDimitry Andric defm _VBUFFER_IDXEN : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 2526*0fca6ea1SDimitry Andric defm _VBUFFER_OFFEN : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 2527*0fca6ea1SDimitry Andric defm _VBUFFER_OFFSET : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 2528*0fca6ea1SDimitry Andric} 2529bdd1243dSDimitry Andric 2530*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_gfx12_Impl2<bits<8> op, string real_name> : 2531*0fca6ea1SDimitry Andric MUBUF_Real_AllAddr_gfx11_Impl2<op, real_name>, 2532*0fca6ea1SDimitry Andric MUBUF_Real_AllAddr_gfx12_Impl2<op, real_name>; 2533*0fca6ea1SDimitry Andric 2534*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_Impl<bits<8> op, bit hasTFE, 2535*0fca6ea1SDimitry Andric string real_name = get_BUF_ps<NAME>.Mnemonic> { 2536*0fca6ea1SDimitry Andric defm NAME : MUBUF_Real_AllAddr_gfx11_Impl2<op, real_name>; 2537bdd1243dSDimitry Andric if hasTFE then 2538*0fca6ea1SDimitry Andric defm _TFE : MUBUF_Real_AllAddr_gfx11_Impl2<op, real_name>; 2539bdd1243dSDimitry Andric} 2540bdd1243dSDimitry Andric 2541*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_gfx12_Impl<bits<8> op, bit hasTFE, 2542*0fca6ea1SDimitry Andric string real_name> { 2543*0fca6ea1SDimitry Andric defm NAME : MUBUF_Real_AllAddr_gfx11_gfx12_Impl2<op, real_name>; 25445f757f3fSDimitry Andric if hasTFE then 2545*0fca6ea1SDimitry Andric defm _TFE : MUBUF_Real_AllAddr_gfx11_gfx12_Impl2<op, real_name>; 25465f757f3fSDimitry Andric} 25475f757f3fSDimitry Andric 25485f757f3fSDimitry Andric// Non-renamed, non-atomic gfx11/gfx12 mubuf instructions. 2549bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11<bits<8> op, bit hasTFE = 1> : 2550*0fca6ea1SDimitry Andric MUBUF_Real_AllAddr_gfx11_Impl<op, hasTFE>; 2551bdd1243dSDimitry Andric 2552*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_gfx12<bits<8> op, 2553*0fca6ea1SDimitry Andric string real_name = get_BUF_ps<NAME>.Mnemonic> : 2554*0fca6ea1SDimitry Andric MUBUF_Real_AllAddr_gfx11_gfx12_Impl<op, /*hasTFE=*/1, real_name> { 2555*0fca6ea1SDimitry Andric defvar ps = get_BUF_ps<NAME>; 2556*0fca6ea1SDimitry Andric if !ne(ps.Mnemonic, real_name) then 2557*0fca6ea1SDimitry Andric def : Mnem_gfx11_gfx12<ps.Mnemonic, real_name>; 255881ad6265SDimitry Andric} 255981ad6265SDimitry Andric 2560*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomic_gfx11_impl<bits<8> op, bit is_return, 2561bdd1243dSDimitry Andric string real_name> { 2562*0fca6ea1SDimitry Andric defvar Rtn = !if(is_return, "_RTN", ""); 2563*0fca6ea1SDimitry Andric defm _BOTHEN#Rtn : MUBUF_Real_gfx11<op, real_name>; 2564*0fca6ea1SDimitry Andric defm _IDXEN#Rtn : MUBUF_Real_gfx11<op, real_name>; 2565*0fca6ea1SDimitry Andric defm _OFFEN#Rtn : MUBUF_Real_gfx11<op, real_name>; 2566*0fca6ea1SDimitry Andric defm _OFFSET#Rtn : MUBUF_Real_gfx11<op, real_name>; 25675f757f3fSDimitry Andric} 256881ad6265SDimitry Andric 2569*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomic_gfx12_impl<bits<8> op, bit is_return, 2570*0fca6ea1SDimitry Andric string real_name = get_BUF_ps<NAME>.Mnemonic> { 2571*0fca6ea1SDimitry Andric defvar Rtn = !if(is_return, "_RTN", ""); 2572*0fca6ea1SDimitry Andric defm _VBUFFER_BOTHEN#Rtn : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 2573*0fca6ea1SDimitry Andric defm _VBUFFER_IDXEN#Rtn : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 2574*0fca6ea1SDimitry Andric defm _VBUFFER_OFFEN#Rtn : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 2575*0fca6ea1SDimitry Andric defm _VBUFFER_OFFSET#Rtn : VBUFFER_MUBUF_Real_gfx12<op, real_name>; 25765f757f3fSDimitry Andric} 25775f757f3fSDimitry Andric 2578*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomic_gfx11_gfx12_impl<bits<8> op, bit is_return, 25795f757f3fSDimitry Andric string real_name> : 2580*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx11_impl<op, is_return, real_name>, 2581*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx12_impl<op, is_return, real_name>; 25825f757f3fSDimitry Andric 25835f757f3fSDimitry Andricmulticlass MUBUF_Real_Atomic_gfx12<bits<8> op> : 2584*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx12_impl<op, 0>, 2585*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx12_impl<op, 1>; 258681ad6265SDimitry Andric 2587*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomic_gfx11<bits<8> op, string real_name> : 2588*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx11_impl<op, 0, real_name>, 2589*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx11_impl<op, 1, real_name> { 2590*0fca6ea1SDimitry Andric defvar ps = get_BUF_ps<NAME>; 2591*0fca6ea1SDimitry Andric def : Mnem_gfx11_gfx12<ps.Mnemonic, real_name>; 2592bdd1243dSDimitry Andric} 259381ad6265SDimitry Andric 2594*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomic_gfx11_gfx12<bits<8> op, 2595*0fca6ea1SDimitry Andric string gfx12_name = get_BUF_ps<NAME>.Mnemonic, 2596*0fca6ea1SDimitry Andric string gfx11_name = gfx12_name> : 2597*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx11_impl<op, 0, gfx11_name>, 2598*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx11_impl<op, 1, gfx11_name>, 2599*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx12_impl<op, 0, gfx12_name>, 2600*0fca6ea1SDimitry Andric MUBUF_Real_Atomic_gfx12_impl<op, 1, gfx12_name> { 2601*0fca6ea1SDimitry Andric defvar ps = get_BUF_ps<NAME>; 2602*0fca6ea1SDimitry Andric if !ne(ps.Mnemonic, gfx11_name) then 2603*0fca6ea1SDimitry Andric def : Mnem_gfx11<ps.Mnemonic, gfx11_name>; 2604*0fca6ea1SDimitry Andric if !ne(ps.Mnemonic, gfx12_name) then 2605*0fca6ea1SDimitry Andric def : Mnem_gfx12<ps.Mnemonic, gfx12_name>; 2606*0fca6ea1SDimitry Andric if !ne(gfx11_name, gfx12_name) then 26075f757f3fSDimitry Andric def : Mnem_gfx12<gfx11_name, gfx12_name>; 26085f757f3fSDimitry Andric} 26095f757f3fSDimitry Andric 2610*0fca6ea1SDimitry Andricdefm BUFFER_GL0_INV : MUBUF_Real_gfx11<0x02B>; 2611*0fca6ea1SDimitry Andricdefm BUFFER_GL1_INV : MUBUF_Real_gfx11<0x02C>; 261281ad6265SDimitry Andric 2613*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_DWORD : MUBUF_Real_AllAddr_gfx11_gfx12<0x014, "buffer_load_b32">; 2614*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_DWORDX2 : MUBUF_Real_AllAddr_gfx11_gfx12<0x015, "buffer_load_b64">; 2615*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_DWORDX3 : MUBUF_Real_AllAddr_gfx11_gfx12<0x016, "buffer_load_b96">; 2616*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_DWORDX4 : MUBUF_Real_AllAddr_gfx11_gfx12<0x017, "buffer_load_b128">; 2617*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_SHORT_D16 : MUBUF_Real_AllAddr_gfx11_gfx12<0x020, "buffer_load_d16_b16">; 2618*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Real_AllAddr_gfx11_gfx12<0x008, "buffer_load_d16_format_x">; 2619*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Real_AllAddr_gfx11_gfx12<0x009, "buffer_load_d16_format_xy">; 2620*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_gfx11_gfx12<0x00a, "buffer_load_d16_format_xyz">; 2621*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_gfx11_gfx12<0x00b, "buffer_load_d16_format_xyzw">; 2622*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Real_AllAddr_gfx11_gfx12<0x023, "buffer_load_d16_hi_b16">; 2623*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_gfx11_gfx12<0x026, "buffer_load_d16_hi_format_x">; 2624*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Real_AllAddr_gfx11_gfx12<0x022, "buffer_load_d16_hi_i8">; 2625*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Real_AllAddr_gfx11_gfx12<0x021, "buffer_load_d16_hi_u8">; 2626*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16 : MUBUF_Real_AllAddr_gfx11_gfx12<0x01f, "buffer_load_d16_i8">; 2627*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16 : MUBUF_Real_AllAddr_gfx11_gfx12<0x01e, "buffer_load_d16_u8">; 26285f757f3fSDimitry Andricdefm BUFFER_LOAD_FORMAT_X : MUBUF_Real_AllAddr_gfx11_gfx12<0x000>; 26295f757f3fSDimitry Andricdefm BUFFER_LOAD_FORMAT_XY : MUBUF_Real_AllAddr_gfx11_gfx12<0x001>; 26305f757f3fSDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Real_AllAddr_gfx11_gfx12<0x002>; 26315f757f3fSDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Real_AllAddr_gfx11_gfx12<0x003>; 2632*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_SBYTE : MUBUF_Real_AllAddr_gfx11_gfx12<0x011, "buffer_load_i8">; 2633*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_SSHORT : MUBUF_Real_AllAddr_gfx11_gfx12<0x013, "buffer_load_i16">; 2634*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_UBYTE : MUBUF_Real_AllAddr_gfx11_gfx12<0x010, "buffer_load_u8">; 2635*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_USHORT : MUBUF_Real_AllAddr_gfx11_gfx12<0x012, "buffer_load_u16">; 2636bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_B32 : MUBUF_Real_AllAddr_gfx11<0x031, 0>; 2637bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_FORMAT_X : MUBUF_Real_AllAddr_gfx11<0x032, 0>; 2638bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_I8 : MUBUF_Real_AllAddr_gfx11<0x02e, 0>; 2639bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_I16 : MUBUF_Real_AllAddr_gfx11<0x030, 0>; 2640bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_U8 : MUBUF_Real_AllAddr_gfx11<0x02d, 0>; 2641bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_U16 : MUBUF_Real_AllAddr_gfx11<0x02f, 0>; 2642*0fca6ea1SDimitry Andricdefm BUFFER_STORE_BYTE : MUBUF_Real_AllAddr_gfx11_gfx12<0x018, "buffer_store_b8">; 2643*0fca6ea1SDimitry Andricdefm BUFFER_STORE_SHORT : MUBUF_Real_AllAddr_gfx11_gfx12<0x019, "buffer_store_b16">; 2644*0fca6ea1SDimitry Andricdefm BUFFER_STORE_DWORD : MUBUF_Real_AllAddr_gfx11_gfx12<0x01A, "buffer_store_b32">; 2645*0fca6ea1SDimitry Andricdefm BUFFER_STORE_DWORDX2 : MUBUF_Real_AllAddr_gfx11_gfx12<0x01B, "buffer_store_b64">; 2646*0fca6ea1SDimitry Andricdefm BUFFER_STORE_DWORDX3 : MUBUF_Real_AllAddr_gfx11_gfx12<0x01C, "buffer_store_b96">; 2647*0fca6ea1SDimitry Andricdefm BUFFER_STORE_DWORDX4 : MUBUF_Real_AllAddr_gfx11_gfx12<0x01D, "buffer_store_b128">; 2648*0fca6ea1SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_X : MUBUF_Real_AllAddr_gfx11_gfx12<0x00C, "buffer_store_d16_format_x">; 2649*0fca6ea1SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Real_AllAddr_gfx11_gfx12<0x00D, "buffer_store_d16_format_xy">; 2650*0fca6ea1SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_gfx11_gfx12<0x00E, "buffer_store_d16_format_xyz">; 2651*0fca6ea1SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_gfx11_gfx12<0x00F, "buffer_store_d16_format_xyzw">; 2652*0fca6ea1SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI : MUBUF_Real_AllAddr_gfx11_gfx12<0x024, "buffer_store_d16_hi_b8">; 2653*0fca6ea1SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI : MUBUF_Real_AllAddr_gfx11_gfx12<0x025, "buffer_store_d16_hi_b16">; 2654*0fca6ea1SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_gfx11_gfx12<0x027, "buffer_store_d16_hi_format_x">; 26555f757f3fSDimitry Andricdefm BUFFER_STORE_FORMAT_X : MUBUF_Real_AllAddr_gfx11_gfx12<0x004>; 26565f757f3fSDimitry Andricdefm BUFFER_STORE_FORMAT_XY : MUBUF_Real_AllAddr_gfx11_gfx12<0x005>; 26575f757f3fSDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ : MUBUF_Real_AllAddr_gfx11_gfx12<0x006>; 26585f757f3fSDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Real_AllAddr_gfx11_gfx12<0x007>; 26595f757f3fSDimitry Andricdefm BUFFER_ATOMIC_ADD_F32 : MUBUF_Real_Atomic_gfx11_gfx12<0x056>; 2660*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_ADD : MUBUF_Real_Atomic_gfx11_gfx12<0x035, "buffer_atomic_add_u32">; 2661*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x043, "buffer_atomic_add_u64">; 2662*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_AND : MUBUF_Real_Atomic_gfx11_gfx12<0x03C, "buffer_atomic_and_b32">; 2663*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_AND_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x049, "buffer_atomic_and_b64">; 2664*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP : MUBUF_Real_Atomic_gfx11_gfx12<0x034, "buffer_atomic_cmpswap_b32">; 2665*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x042, "buffer_atomic_cmpswap_b64">; 2666*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP : MUBUF_Real_Atomic_gfx11<0x050, "buffer_atomic_cmpswap_f32">; 26677a6dacacSDimitry Andricdefm BUFFER_ATOMIC_COND_SUB_U32 : MUBUF_Real_Atomic_gfx12<0x050>; 2668*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_CSUB : MUBUF_Real_Atomic_gfx11_gfx12<0x037, "buffer_atomic_sub_clamp_u32", "buffer_atomic_csub_u32">; 2669*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_DEC : MUBUF_Real_Atomic_gfx11_gfx12<0x040, "buffer_atomic_dec_u32">; 2670*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x04D, "buffer_atomic_dec_u64">; 2671*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_INC : MUBUF_Real_Atomic_gfx11_gfx12<0x03F, "buffer_atomic_inc_u32">; 2672*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_INC_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x04C, "buffer_atomic_inc_u64">; 2673*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_FMAX : MUBUF_Real_Atomic_gfx11_gfx12<0x052, "buffer_atomic_max_num_f32", "buffer_atomic_max_f32">; 2674*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SMAX : MUBUF_Real_Atomic_gfx11_gfx12<0x03A, "buffer_atomic_max_i32">; 2675*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x047, "buffer_atomic_max_i64">; 2676*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_UMAX : MUBUF_Real_Atomic_gfx11_gfx12<0x03B, "buffer_atomic_max_u32">; 2677*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x048, "buffer_atomic_max_u64">; 2678*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_FMIN : MUBUF_Real_Atomic_gfx11_gfx12<0x051, "buffer_atomic_min_num_f32", "buffer_atomic_min_f32">; 2679*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SMIN : MUBUF_Real_Atomic_gfx11_gfx12<0x038, "buffer_atomic_min_i32">; 2680*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x045, "buffer_atomic_min_i64">; 2681*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_UMIN : MUBUF_Real_Atomic_gfx11_gfx12<0x039, "buffer_atomic_min_u32">; 2682*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x046, "buffer_atomic_min_u64">; 2683*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_OR : MUBUF_Real_Atomic_gfx11_gfx12<0x03D, "buffer_atomic_or_b32">; 2684*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_OR_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x04A, "buffer_atomic_or_b64">; 2685*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SUB : MUBUF_Real_Atomic_gfx11_gfx12<0x036, "buffer_atomic_sub_u32">; 2686*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x044, "buffer_atomic_sub_u64">; 2687*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SWAP : MUBUF_Real_Atomic_gfx11_gfx12<0x033, "buffer_atomic_swap_b32">; 2688*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x041, "buffer_atomic_swap_b64">; 2689*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_XOR : MUBUF_Real_Atomic_gfx11_gfx12<0x03E, "buffer_atomic_xor_b32">; 2690*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2 : MUBUF_Real_Atomic_gfx11_gfx12<0x04B, "buffer_atomic_xor_b64">; 26917a6dacacSDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Real_Atomic_gfx12<0x059>; 26927a6dacacSDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_BF16 : MUBUF_Real_Atomic_gfx12<0x05a>; 269381ad6265SDimitry Andric 269481ad6265SDimitry Andric//===----------------------------------------------------------------------===// 26950b57cec5SDimitry Andric// MUBUF - GFX10. 26960b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 26970b57cec5SDimitry Andric 2698bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Helper_gfx10<bits<8> op> { 2699*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx10<op>; 2700*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx10<op>; 2701*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx10<op>; 2702*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx10<op>; 27030b57cec5SDimitry Andric} 2704bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx10<bits<8> op> { 2705bdd1243dSDimitry Andric defm NAME : MUBUF_Real_AllAddr_Helper_gfx10<op>; 2706bdd1243dSDimitry Andric defm _TFE : MUBUF_Real_AllAddr_Helper_gfx10<op>; 2707bdd1243dSDimitry Andric} 2708bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_gfx10<bits<8> op, bit isTFE = 0> { 2709*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx10<op>; 2710*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx10<op>; 2711*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx10<op>; 2712*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx10<op>; 27130b57cec5SDimitry Andric 2714bdd1243dSDimitry Andric if !not(isTFE) then { 2715*0fca6ea1SDimitry Andric defm _LDS_OFFSET : MUBUF_Real_gfx10<op>; 2716*0fca6ea1SDimitry Andric defm _LDS_OFFEN : MUBUF_Real_gfx10<op>; 2717*0fca6ea1SDimitry Andric defm _LDS_IDXEN : MUBUF_Real_gfx10<op>; 2718*0fca6ea1SDimitry Andric defm _LDS_BOTHEN : MUBUF_Real_gfx10<op>; 27190b57cec5SDimitry Andric } 2720bdd1243dSDimitry Andric} 2721*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomics_RTN_gfx10<bits<8> op, string psName = NAME, 2722*0fca6ea1SDimitry Andric string asmName = !cast<MUBUF_Pseudo>(psName).Mnemonic> { 2723*0fca6ea1SDimitry Andric defm _BOTHEN_RTN : MUBUF_Real_gfx10<op, psName#"_BOTHEN_RTN", asmName>; 2724*0fca6ea1SDimitry Andric defm _IDXEN_RTN : MUBUF_Real_gfx10<op, psName#"_IDXEN_RTN", asmName>; 2725*0fca6ea1SDimitry Andric defm _OFFEN_RTN : MUBUF_Real_gfx10<op, psName#"_OFFEN_RTN", asmName>; 2726*0fca6ea1SDimitry Andric defm _OFFSET_RTN : MUBUF_Real_gfx10<op, psName#"_OFFSET_RTN", asmName>; 27270b57cec5SDimitry Andric} 2728*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomics_gfx10<bits<8> op, string psName = NAME, 2729*0fca6ea1SDimitry Andric string asmName = get_BUF_ps<psName>.Mnemonic> : 2730*0fca6ea1SDimitry Andric MUBUF_Real_Atomics_RTN_gfx10<op, psName, asmName> { 2731*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx10<op, psName#"_BOTHEN", asmName>; 2732*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx10<op, psName#"_IDXEN", asmName>; 2733*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx10<op, psName#"_OFFEN", asmName>; 2734*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx10<op, psName#"_OFFSET", asmName>; 2735fe6060f1SDimitry Andric} 27360b57cec5SDimitry Andric 27370b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI : MUBUF_Real_AllAddr_gfx10<0x019>; 27380b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI : MUBUF_Real_AllAddr_gfx10<0x01b>; 27390b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16 : MUBUF_Real_AllAddr_gfx10<0x020>; 27400b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Real_AllAddr_gfx10<0x021>; 27410b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16 : MUBUF_Real_AllAddr_gfx10<0x022>; 27420b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Real_AllAddr_gfx10<0x023>; 27430b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16 : MUBUF_Real_AllAddr_gfx10<0x024>; 27440b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Real_AllAddr_gfx10<0x025>; 2745*0fca6ea1SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_gfx10<0x026>; 2746*0fca6ea1SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_gfx10<0x027>; 27470b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Real_AllAddr_gfx10<0x080>; 27480b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Real_AllAddr_gfx10<0x081>; 27490b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_gfx10<0x082>; 27500b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_gfx10<0x083>; 27510b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_X : MUBUF_Real_AllAddr_gfx10<0x084>; 27520b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Real_AllAddr_gfx10<0x085>; 27530b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_gfx10<0x086>; 27540b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_gfx10<0x087>; 27550b57cec5SDimitry Andric 2756*0fca6ea1SDimitry Andricdefm BUFFER_GL0_INV : MUBUF_Real_gfx10<0x071>; 2757*0fca6ea1SDimitry Andricdefm BUFFER_GL1_INV : MUBUF_Real_gfx10<0x072>; 27580b57cec5SDimitry Andric 27590b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 27600b57cec5SDimitry Andric// MUBUF - GFX6, GFX7, GFX10. 27610b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 27620b57cec5SDimitry Andric 2763bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Helper_gfx6_gfx7<bits<8> op> { 2764*0fca6ea1SDimitry Andric defm _ADDR64 : MUBUF_Real_gfx6_gfx7<op>; 2765*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx6_gfx7<op>; 2766*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx6_gfx7<op>; 2767*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx6_gfx7<op>; 2768*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx6_gfx7<op>; 27690b57cec5SDimitry Andric} 2770bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx6_gfx7<bits<8> op> { 2771bdd1243dSDimitry Andric defm NAME : MUBUF_Real_AllAddr_Helper_gfx6_gfx7<op>; 2772bdd1243dSDimitry Andric defm _TFE : MUBUF_Real_AllAddr_Helper_gfx6_gfx7<op>; 2773bdd1243dSDimitry Andric} 2774bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_gfx6_gfx7<bits<8> op, bit isTFE = 0> { 2775*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx6_gfx7<op>; 2776*0fca6ea1SDimitry Andric defm _ADDR64 : MUBUF_Real_gfx6_gfx7<op>; 2777*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx6_gfx7<op>; 2778*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx6_gfx7<op>; 2779*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx6_gfx7<op>; 27800b57cec5SDimitry Andric 2781bdd1243dSDimitry Andric if !not(isTFE) then { 2782*0fca6ea1SDimitry Andric defm _LDS_OFFSET : MUBUF_Real_gfx6_gfx7<op>; 2783*0fca6ea1SDimitry Andric defm _LDS_ADDR64 : MUBUF_Real_gfx6_gfx7<op>; 2784*0fca6ea1SDimitry Andric defm _LDS_OFFEN : MUBUF_Real_gfx6_gfx7<op>; 2785*0fca6ea1SDimitry Andric defm _LDS_IDXEN : MUBUF_Real_gfx6_gfx7<op>; 2786*0fca6ea1SDimitry Andric defm _LDS_BOTHEN : MUBUF_Real_gfx6_gfx7<op>; 27870b57cec5SDimitry Andric } 2788bdd1243dSDimitry Andric} 2789*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomics_gfx6_gfx7<bits<8> op, string psName, string asmName> { 2790*0fca6ea1SDimitry Andric defm _ADDR64 : MUBUF_Real_gfx6_gfx7<op, psName#"_ADDR64", asmName>; 2791*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx6_gfx7<op, psName#"_BOTHEN", asmName>; 2792*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx6_gfx7<op, psName#"_IDXEN", asmName>; 2793*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx6_gfx7<op, psName#"_OFFEN", asmName>; 2794*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx6_gfx7<op, psName#"_OFFSET", asmName>; 2795fe6060f1SDimitry Andric 2796*0fca6ea1SDimitry Andric defm _ADDR64_RTN : MUBUF_Real_gfx6_gfx7<op, psName#"_ADDR64_RTN", asmName>; 2797*0fca6ea1SDimitry Andric defm _BOTHEN_RTN : MUBUF_Real_gfx6_gfx7<op, psName#"_BOTHEN_RTN", asmName>; 2798*0fca6ea1SDimitry Andric defm _IDXEN_RTN : MUBUF_Real_gfx6_gfx7<op, psName#"_IDXEN_RTN", asmName>; 2799*0fca6ea1SDimitry Andric defm _OFFEN_RTN : MUBUF_Real_gfx6_gfx7<op, psName#"_OFFEN_RTN", asmName>; 2800*0fca6ea1SDimitry Andric defm _OFFSET_RTN : MUBUF_Real_gfx6_gfx7<op, psName#"_OFFSET_RTN", asmName>; 28010b57cec5SDimitry Andric} 28020b57cec5SDimitry Andric 28030b57cec5SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<bits<8> op> : 28040b57cec5SDimitry Andric MUBUF_Real_AllAddr_gfx6_gfx7<op>, MUBUF_Real_AllAddr_gfx10<op>; 28050b57cec5SDimitry Andric 2806bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_Helper_gfx6_gfx7_gfx10<bits<8> op, bit isTFE = 0> : 2807bdd1243dSDimitry Andric MUBUF_Real_AllAddr_Lds_gfx6_gfx7<op, isTFE>, 2808bdd1243dSDimitry Andric MUBUF_Real_AllAddr_Lds_gfx10<op, isTFE>; 2809bdd1243dSDimitry Andric 2810bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<bits<8> op> { 2811bdd1243dSDimitry Andric defm NAME : MUBUF_Real_AllAddr_Lds_Helper_gfx6_gfx7_gfx10<op>; 2812bdd1243dSDimitry Andric defm _TFE : MUBUF_Real_AllAddr_Lds_Helper_gfx6_gfx7_gfx10<op, 1>; 2813bdd1243dSDimitry Andric} 28140b57cec5SDimitry Andric 2815*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_Atomics_gfx6_gfx7_gfx10<bits<8> op, string psName = NAME, 2816*0fca6ea1SDimitry Andric string asmName = get_BUF_ps<psName>.Mnemonic> : 2817*0fca6ea1SDimitry Andric MUBUF_Real_Atomics_gfx6_gfx7<op, psName, asmName>, 2818*0fca6ea1SDimitry Andric MUBUF_Real_Atomics_gfx10<op, psName, asmName>; 28190b57cec5SDimitry Andric 28200b57cec5SDimitry Andric// FIXME-GFX6: Following instructions are available only on GFX6. 28210b57cec5SDimitry Andric//defm BUFFER_ATOMIC_RSUB : MUBUF_Real_Atomics_gfx6 <0x034>; 28220b57cec5SDimitry Andric//defm BUFFER_ATOMIC_RSUB_X2 : MUBUF_Real_Atomics_gfx6 <0x054>; 28230b57cec5SDimitry Andric 28240b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x000>; 28250b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x001>; 28260b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x002>; 28270b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x003>; 28280b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x004>; 28290b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x005>; 28300b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x006>; 28310b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x007>; 28320b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x008>; 28330b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x009>; 28340b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00a>; 28350b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00b>; 28360b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00c>; 28370b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2 : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00d>; 28380b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4 : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00e>; 28390b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3 : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00f>; 28400b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x018>; 28410b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01a>; 28420b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01c>; 28430b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2 : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01d>; 28440b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4 : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01e>; 28450b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3 : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01f>; 28460b57cec5SDimitry Andric 28470b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x030>; 28480b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x031>; 28490b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x032>; 28500b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x033>; 28510b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x035>; 28520b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x036>; 28530b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x037>; 28540b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x038>; 28550b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x039>; 28560b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03a>; 28570b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03b>; 28580b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03c>; 28590b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03d>; 28608bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03e>; 28618bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03f>; 28628bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x040>; 28630b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x050>; 28640b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x051>; 28650b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x052>; 28660b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x053>; 28670b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x055>; 28680b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x056>; 28690b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x057>; 28700b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x058>; 28710b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x059>; 28720b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05a>; 28730b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05b>; 28740b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05c>; 28750b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05d>; 28760b57cec5SDimitry Andric// FIXME-GFX7: Need to handle hazard for BUFFER_ATOMIC_FCMPSWAP_X2 on GFX7. 28778bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05e>; 2878*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_FMIN_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05f, "BUFFER_ATOMIC_MIN_F64", "buffer_atomic_fmin_x2">; 2879*0fca6ea1SDimitry Andricdefm BUFFER_ATOMIC_FMAX_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x060, "BUFFER_ATOMIC_MAX_F64", "buffer_atomic_fmax_x2">; 28800b57cec5SDimitry Andric 28815f757f3fSDimitry Andricdefm BUFFER_ATOMIC_CSUB : MUBUF_Real_Atomics_gfx10<0x034>; 28825ffd83dbSDimitry Andric 28830b57cec5SDimitry Andricdefm BUFFER_WBINVL1_SC : MUBUF_Real_gfx6<0x070>; 28840b57cec5SDimitry Andricdefm BUFFER_WBINVL1_VOL : MUBUF_Real_gfx7<0x070>; 2885*0fca6ea1SDimitry Andricdefm BUFFER_WBINVL1 : MUBUF_Real_gfx6_gfx7<0x071>; 28860b57cec5SDimitry Andric 28870b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 288881ad6265SDimitry Andric// Base ENC_MTBUF for GFX6, GFX7, GFX10, GFX11. 28890b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 28900b57cec5SDimitry Andric 289181ad6265SDimitry Andricclass Base_MTBUF_Real_gfx6_gfx7_gfx10_gfx11<MTBUF_Pseudo ps, int ef, 289281ad6265SDimitry Andric string real_name = ps.Mnemonic> : 289381ad6265SDimitry Andric MTBUF_Real<ps, real_name>, Enc64, SIMCInstr<ps.PseudoInstr, ef> { 28940b57cec5SDimitry Andric let Inst{11-0} = !if(ps.has_offset, offset, ?); 2895fe6060f1SDimitry Andric let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value); 28960b57cec5SDimitry Andric let Inst{31-26} = 0x3a; //encoding 28970b57cec5SDimitry Andric let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?); 2898fe6060f1SDimitry Andric let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?); 28990b57cec5SDimitry Andric let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?); 29000b57cec5SDimitry Andric let Inst{63-56} = !if(ps.has_soffset, soffset, ?); 29010b57cec5SDimitry Andric} 29020b57cec5SDimitry Andric 2903*0fca6ea1SDimitry Andricmulticlass MTBUF_Real_gfx11<bits<4> op, string real_name> { 2904*0fca6ea1SDimitry Andric defvar ps = !cast<MTBUF_Pseudo>(NAME); 2905*0fca6ea1SDimitry Andric def _gfx11 : Base_MTBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, SIEncodingFamily.GFX11, real_name> { 290681ad6265SDimitry Andric let Inst{12} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 290781ad6265SDimitry Andric let Inst{13} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlc_value); 290881ad6265SDimitry Andric let Inst{18-15} = op; 290981ad6265SDimitry Andric let Inst{25-19} = format; 2910bdd1243dSDimitry Andric let Inst{53} = ps.tfe; 291181ad6265SDimitry Andric let Inst{54} = ps.offen; 291281ad6265SDimitry Andric let Inst{55} = ps.idxen; 2913*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX11Only; 2914*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX11"; 2915*0fca6ea1SDimitry Andric } 291681ad6265SDimitry Andric} 291781ad6265SDimitry Andric 291881ad6265SDimitry Andricclass Base_MTBUF_Real_gfx6_gfx7_gfx10<bits<3> op, MTBUF_Pseudo ps, int ef> : 291981ad6265SDimitry Andric Base_MTBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, ef> { 292081ad6265SDimitry Andric let Inst{12} = ps.offen; 292181ad6265SDimitry Andric let Inst{13} = ps.idxen; 292281ad6265SDimitry Andric let Inst{18-16} = op; 292381ad6265SDimitry Andric let Inst{54} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 2924bdd1243dSDimitry Andric let Inst{55} = ps.tfe; 292581ad6265SDimitry Andric} 292681ad6265SDimitry Andric 292781ad6265SDimitry Andric//===----------------------------------------------------------------------===// 292881ad6265SDimitry Andric// MTBUF - GFX11. 292981ad6265SDimitry Andric//===----------------------------------------------------------------------===// 293081ad6265SDimitry Andric 2931*0fca6ea1SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx11_gfx12_Impl<bits<4> op, string real_name> { 2932*0fca6ea1SDimitry Andric defm _BOTHEN : MTBUF_Real_gfx11<op, real_name>; 2933*0fca6ea1SDimitry Andric defm _IDXEN : MTBUF_Real_gfx11<op, real_name>; 2934*0fca6ea1SDimitry Andric defm _OFFEN : MTBUF_Real_gfx11<op, real_name>; 2935*0fca6ea1SDimitry Andric defm _OFFSET : MTBUF_Real_gfx11<op, real_name>; 2936*0fca6ea1SDimitry Andric 2937*0fca6ea1SDimitry Andric defm _VBUFFER_BOTHEN : VBUFFER_MTBUF_Real_gfx12<op, real_name>; 2938*0fca6ea1SDimitry Andric defm _VBUFFER_IDXEN : VBUFFER_MTBUF_Real_gfx12<op, real_name>; 2939*0fca6ea1SDimitry Andric defm _VBUFFER_OFFEN : VBUFFER_MTBUF_Real_gfx12<op, real_name>; 2940*0fca6ea1SDimitry Andric defm _VBUFFER_OFFSET : VBUFFER_MTBUF_Real_gfx12<op, real_name>; 294181ad6265SDimitry Andric} 294281ad6265SDimitry Andric 2943*0fca6ea1SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx11_gfx12<bits<4> op, 2944*0fca6ea1SDimitry Andric string real_name = get_BUF_ps<NAME>.Mnemonic> 2945*0fca6ea1SDimitry Andric : MTBUF_Real_AllAddr_gfx11_gfx12_Impl<op, real_name> { 2946*0fca6ea1SDimitry Andric defvar ps = get_BUF_ps<NAME>; 2947*0fca6ea1SDimitry Andric if !ne(ps.Mnemonic, real_name) then 2948*0fca6ea1SDimitry Andric def : Mnem_gfx11_gfx12<ps.Mnemonic, real_name>; 29495f757f3fSDimitry Andric} 29505f757f3fSDimitry Andric 2951*0fca6ea1SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_X : MTBUF_Real_AllAddr_gfx11_gfx12<0x008, "tbuffer_load_d16_format_x">; 2952*0fca6ea1SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XY : MTBUF_Real_AllAddr_gfx11_gfx12<0x009, "tbuffer_load_d16_format_xy">; 2953*0fca6ea1SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_gfx11_gfx12<0x00a, "tbuffer_load_d16_format_xyz">; 2954*0fca6ea1SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_gfx11_gfx12<0x00b, "tbuffer_load_d16_format_xyzw">; 29555f757f3fSDimitry Andricdefm TBUFFER_LOAD_FORMAT_X : MTBUF_Real_AllAddr_gfx11_gfx12<0x000>; 29565f757f3fSDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY : MTBUF_Real_AllAddr_gfx11_gfx12<0x001>; 29575f757f3fSDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ : MTBUF_Real_AllAddr_gfx11_gfx12<0x002>; 29585f757f3fSDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Real_AllAddr_gfx11_gfx12<0x003>; 2959*0fca6ea1SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_X : MTBUF_Real_AllAddr_gfx11_gfx12<0x00c, "tbuffer_store_d16_format_x">; 2960*0fca6ea1SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XY : MTBUF_Real_AllAddr_gfx11_gfx12<0x00d, "tbuffer_store_d16_format_xy">; 2961*0fca6ea1SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_gfx11_gfx12<0x00e, "tbuffer_store_d16_format_xyz">; 2962*0fca6ea1SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_gfx11_gfx12<0x00f, "tbuffer_store_d16_format_xyzw">; 29635f757f3fSDimitry Andricdefm TBUFFER_STORE_FORMAT_X : MTBUF_Real_AllAddr_gfx11_gfx12<0x004>; 29645f757f3fSDimitry Andricdefm TBUFFER_STORE_FORMAT_XY : MTBUF_Real_AllAddr_gfx11_gfx12<0x005>; 29655f757f3fSDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Real_AllAddr_gfx11_gfx12<0x006>; 29665f757f3fSDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_gfx11_gfx12<0x007>; 296781ad6265SDimitry Andric 29680b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 29690b57cec5SDimitry Andric// MTBUF - GFX10. 29700b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 29710b57cec5SDimitry Andric 2972*0fca6ea1SDimitry Andricmulticlass MTBUF_Real_gfx10<bits<4> op> { 2973*0fca6ea1SDimitry Andric defvar ps = !cast<MTBUF_Pseudo>(NAME); 2974*0fca6ea1SDimitry Andric def _gfx10 : Base_MTBUF_Real_gfx6_gfx7_gfx10<op{2-0}, ps, SIEncodingFamily.GFX10> { 2975fe6060f1SDimitry Andric let Inst{15} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlc_value); 29760b57cec5SDimitry Andric let Inst{25-19} = format; 29770b57cec5SDimitry Andric let Inst{53} = op{3}; 2978*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX10Only; 2979*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX10"; 2980*0fca6ea1SDimitry Andric } 29810b57cec5SDimitry Andric} 29820b57cec5SDimitry Andric 29830b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx10<bits<4> op> { 2984*0fca6ea1SDimitry Andric defm _BOTHEN : MTBUF_Real_gfx10<op>; 2985*0fca6ea1SDimitry Andric defm _IDXEN : MTBUF_Real_gfx10<op>; 2986*0fca6ea1SDimitry Andric defm _OFFEN : MTBUF_Real_gfx10<op>; 2987*0fca6ea1SDimitry Andric defm _OFFSET : MTBUF_Real_gfx10<op>; 29880b57cec5SDimitry Andric} 29890b57cec5SDimitry Andric 29900b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_X : MTBUF_Real_AllAddr_gfx10<0x008>; 29910b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XY : MTBUF_Real_AllAddr_gfx10<0x009>; 29920b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_gfx10<0x00a>; 29930b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_gfx10<0x00b>; 29940b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_X : MTBUF_Real_AllAddr_gfx10<0x00c>; 29950b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XY : MTBUF_Real_AllAddr_gfx10<0x00d>; 29960b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_gfx10<0x00e>; 29970b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_gfx10<0x00f>; 29980b57cec5SDimitry Andric 29990b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 30000b57cec5SDimitry Andric// MTBUF - GFX6, GFX7, GFX10. 30010b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 30020b57cec5SDimitry Andric 3003*0fca6ea1SDimitry Andricmulticlass MTBUF_Real_gfx6_gfx7<bits<4> op> { 3004*0fca6ea1SDimitry Andric defvar ps = !cast<MTBUF_Pseudo>(NAME); 3005*0fca6ea1SDimitry Andric def _gfx6_gfx7 : Base_MTBUF_Real_gfx6_gfx7_gfx10<op{2-0}, ps, SIEncodingFamily.SI> { 30060b57cec5SDimitry Andric let Inst{15} = ps.addr64; 30070b57cec5SDimitry Andric let Inst{22-19} = dfmt; 30080b57cec5SDimitry Andric let Inst{25-23} = nfmt; 3009*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX6GFX7; 3010*0fca6ea1SDimitry Andric let DecoderNamespace = "GFX6GFX7"; 3011*0fca6ea1SDimitry Andric } 30120b57cec5SDimitry Andric} 30130b57cec5SDimitry Andric 30140b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx6_gfx7<bits<4> op> { 3015*0fca6ea1SDimitry Andric defm _ADDR64 : MTBUF_Real_gfx6_gfx7<op>; 3016*0fca6ea1SDimitry Andric defm _BOTHEN : MTBUF_Real_gfx6_gfx7<op>; 3017*0fca6ea1SDimitry Andric defm _IDXEN : MTBUF_Real_gfx6_gfx7<op>; 3018*0fca6ea1SDimitry Andric defm _OFFEN : MTBUF_Real_gfx6_gfx7<op>; 3019*0fca6ea1SDimitry Andric defm _OFFSET : MTBUF_Real_gfx6_gfx7<op>; 30200b57cec5SDimitry Andric} 30210b57cec5SDimitry Andric 30220b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<bits<4> op> : 30230b57cec5SDimitry Andric MTBUF_Real_AllAddr_gfx6_gfx7<op>, MTBUF_Real_AllAddr_gfx10<op>; 30240b57cec5SDimitry Andric 30250b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x000>; 30260b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x001>; 30270b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x002>; 30280b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x003>; 30290b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_X : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x004>; 30300b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x005>; 30310b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x006>; 30320b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x007>; 30330b57cec5SDimitry Andric 30340b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 30350b57cec5SDimitry Andric// GFX8, GFX9 (VI). 30360b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 30370b57cec5SDimitry Andric 3038fe6060f1SDimitry Andricclass MUBUF_Real_Base_vi <bits<7> op, MUBUF_Pseudo ps, int Enc, 3039fe6060f1SDimitry Andric bit has_sccb = ps.has_sccb> : 30400b57cec5SDimitry Andric MUBUF_Real<ps>, 30410b57cec5SDimitry Andric Enc64, 3042*0fca6ea1SDimitry Andric SIMCInstr<ps.PseudoInstr, Enc> { 30430b57cec5SDimitry Andric 30440b57cec5SDimitry Andric let Inst{11-0} = !if(ps.has_offset, offset, ?); 30450b57cec5SDimitry Andric let Inst{12} = ps.offen; 30460b57cec5SDimitry Andric let Inst{13} = ps.idxen; 3047fe6060f1SDimitry Andric let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value); 3048fe6060f1SDimitry Andric let Inst{15} = !if(has_sccb, cpol{CPolBit.SCC}, ps.sccb_value); 3049e8d8bef9SDimitry Andric let Inst{16} = ps.lds; 3050fe6060f1SDimitry Andric let Inst{17} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 30510b57cec5SDimitry Andric let Inst{24-18} = op; 30520b57cec5SDimitry Andric let Inst{31-26} = 0x38; //encoding 30530b57cec5SDimitry Andric let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?); 3054fe6060f1SDimitry Andric let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?); 30550b57cec5SDimitry Andric let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?); 30560b57cec5SDimitry Andric let Inst{63-56} = !if(ps.has_soffset, soffset, ?); 30570b57cec5SDimitry Andric} 30580b57cec5SDimitry Andric 3059*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_vi <bits<7> op, 3060*0fca6ea1SDimitry Andric bit has_sccb = !cast<MUBUF_Pseudo>(NAME).has_sccb> { 3061*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 3062*0fca6ea1SDimitry Andric def _vi : MUBUF_Real_Base_vi<op, ps, SIEncodingFamily.VI, has_sccb> { 3063fe6060f1SDimitry Andric let AssemblerPredicate = isGFX8GFX9NotGFX90A; 3064fe6060f1SDimitry Andric let DecoderNamespace = "GFX8"; 3065fe6060f1SDimitry Andric 3066bdd1243dSDimitry Andric let Inst{55} = ps.tfe; 3067fe6060f1SDimitry Andric } 3068*0fca6ea1SDimitry Andric} 3069fe6060f1SDimitry Andric 3070*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_gfx90a <bits<7> op, 3071*0fca6ea1SDimitry Andric bit has_sccb = !cast<MUBUF_Pseudo>(NAME).has_sccb> { 3072*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 3073*0fca6ea1SDimitry Andric def _gfx90a : MUBUF_Real_Base_vi<op, ps, SIEncodingFamily.GFX90A, has_sccb> { 3074fe6060f1SDimitry Andric let AssemblerPredicate = isGFX90APlus; 3075fe6060f1SDimitry Andric let DecoderNamespace = "GFX90A"; 3076fe6060f1SDimitry Andric let AsmString = ps.Mnemonic # !subst("$sccb", !if(has_sccb, "$sccb",""), 3077bdd1243dSDimitry Andric ps.AsmOperands); 3078fe6060f1SDimitry Andric 3079fe6060f1SDimitry Andric let Inst{55} = acc; 3080fe6060f1SDimitry Andric } 3081*0fca6ea1SDimitry Andric} 3082fe6060f1SDimitry Andric 308381ad6265SDimitry Andricclass MUBUF_Real_gfx940 <bits<7> op, MUBUF_Pseudo ps> : 308481ad6265SDimitry Andric MUBUF_Real_Base_vi<op, ps, SIEncodingFamily.GFX940> { 308581ad6265SDimitry Andric let AssemblerPredicate = isGFX940Plus; 308681ad6265SDimitry Andric let DecoderNamespace = "GFX9"; 3087bdd1243dSDimitry Andric let AsmString = ps.Mnemonic # ps.AsmOperands; 308881ad6265SDimitry Andric 308981ad6265SDimitry Andric let Inst{55} = acc; 309081ad6265SDimitry Andric} 309181ad6265SDimitry Andric 3092*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_vi_gfx90a<bits<7> op, bit isTFE = 0> : MUBUF_Real_vi<op> { 3093*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 309481ad6265SDimitry Andric 3095bdd1243dSDimitry Andric if !not(isTFE) then { 309606c3fb27SDimitry Andric if !not(ps.FPAtomic) then 3097*0fca6ea1SDimitry Andric defm NAME : MUBUF_Real_gfx90a<op>; 3098bdd1243dSDimitry Andric } 309981ad6265SDimitry Andric 310006c3fb27SDimitry Andric if ps.FPAtomic then { 3101*0fca6ea1SDimitry Andric let AssemblerPredicate = isGFX90AOnly in 3102*0fca6ea1SDimitry Andric defm NAME : MUBUF_Real_gfx90a<op, 0>; 3103*0fca6ea1SDimitry Andric 310481ad6265SDimitry Andric def _gfx940 : MUBUF_Real_gfx940<op, ps>; 310581ad6265SDimitry Andric } 3106fe6060f1SDimitry Andric} 3107fe6060f1SDimitry Andric 3108bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Helper_vi<bits<7> op, bit isTFE = 0> { 3109*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_vi_gfx90a <op, isTFE>; 3110*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_vi_gfx90a <op, isTFE>; 3111*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_vi_gfx90a <op, isTFE>; 3112*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_vi_gfx90a <op, isTFE>; 31130b57cec5SDimitry Andric} 31140b57cec5SDimitry Andric 3115bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_vi<bits<7> op, bit hasTFE = 1> { 3116bdd1243dSDimitry Andric defm NAME : MUBUF_Real_AllAddr_Helper_vi<op>; 3117bdd1243dSDimitry Andric if hasTFE then 3118bdd1243dSDimitry Andric defm _TFE : MUBUF_Real_AllAddr_Helper_vi<op, 1>; 3119bdd1243dSDimitry Andric} 31200b57cec5SDimitry Andric 3121bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_Helper_vi<bits<7> op, bit isTFE = 0> { 3122*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_vi <op>; 3123*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_vi <op>; 3124*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_vi <op>; 3125*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_vi <op>; 31260b57cec5SDimitry Andric 3127bdd1243dSDimitry Andric if !not(isTFE) then { 3128*0fca6ea1SDimitry Andric defm _LDS_OFFSET : MUBUF_Real_vi <op>; 3129*0fca6ea1SDimitry Andric defm _LDS_OFFEN : MUBUF_Real_vi <op>; 3130*0fca6ea1SDimitry Andric defm _LDS_IDXEN : MUBUF_Real_vi <op>; 3131*0fca6ea1SDimitry Andric defm _LDS_BOTHEN : MUBUF_Real_vi <op>; 3132fe6060f1SDimitry Andric 3133*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx90a <op>; 3134*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx90a <op>; 3135*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx90a <op>; 3136*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx90a <op>; 3137fe6060f1SDimitry Andric 3138*0fca6ea1SDimitry Andric defm _LDS_OFFSET : MUBUF_Real_gfx90a <op>; 3139*0fca6ea1SDimitry Andric defm _LDS_OFFEN : MUBUF_Real_gfx90a <op>; 3140*0fca6ea1SDimitry Andric defm _LDS_IDXEN : MUBUF_Real_gfx90a <op>; 3141*0fca6ea1SDimitry Andric defm _LDS_BOTHEN : MUBUF_Real_gfx90a <op>; 31420b57cec5SDimitry Andric } 3143bdd1243dSDimitry Andric} 3144bdd1243dSDimitry Andric 3145bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_vi<bits<7> op> { 3146bdd1243dSDimitry Andric defm NAME : MUBUF_Real_AllAddr_Lds_Helper_vi<op>; 3147bdd1243dSDimitry Andric defm _TFE : MUBUF_Real_AllAddr_Lds_Helper_vi<op, 1>; 3148bdd1243dSDimitry Andric} 31490b57cec5SDimitry Andric 3150*0fca6ea1SDimitry Andricmulticlass MUBUF_Real_gfx80 <bits<7> op> { 3151*0fca6ea1SDimitry Andric defvar ps = !cast<MUBUF_Pseudo>(NAME); 3152*0fca6ea1SDimitry Andric def _gfx80 : MUBUF_Real<ps>, 31530b57cec5SDimitry Andric Enc64, 31540b57cec5SDimitry Andric SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> { 31550b57cec5SDimitry Andric let AssemblerPredicate=HasUnpackedD16VMem; 31560b57cec5SDimitry Andric let DecoderNamespace="GFX80_UNPACKED"; 31570b57cec5SDimitry Andric 31580b57cec5SDimitry Andric let Inst{11-0} = !if(ps.has_offset, offset, ?); 31590b57cec5SDimitry Andric let Inst{12} = ps.offen; 31600b57cec5SDimitry Andric let Inst{13} = ps.idxen; 3161fe6060f1SDimitry Andric let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value); 3162e8d8bef9SDimitry Andric let Inst{16} = ps.lds; 3163fe6060f1SDimitry Andric let Inst{17} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 31640b57cec5SDimitry Andric let Inst{24-18} = op; 31650b57cec5SDimitry Andric let Inst{31-26} = 0x38; //encoding 31660b57cec5SDimitry Andric let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?); 3167fe6060f1SDimitry Andric let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?); 31680b57cec5SDimitry Andric let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?); 3169bdd1243dSDimitry Andric let Inst{55} = ps.tfe; 31700b57cec5SDimitry Andric let Inst{63-56} = !if(ps.has_soffset, soffset, ?); 31710b57cec5SDimitry Andric } 3172*0fca6ea1SDimitry Andric} 31730b57cec5SDimitry Andric 3174bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Helper_gfx80<bits<7> op> { 3175*0fca6ea1SDimitry Andric defm _OFFSET : MUBUF_Real_gfx80 <op>; 3176*0fca6ea1SDimitry Andric defm _OFFEN : MUBUF_Real_gfx80 <op>; 3177*0fca6ea1SDimitry Andric defm _IDXEN : MUBUF_Real_gfx80 <op>; 3178*0fca6ea1SDimitry Andric defm _BOTHEN : MUBUF_Real_gfx80 <op>; 31790b57cec5SDimitry Andric} 31800b57cec5SDimitry Andric 3181bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx80<bits<7> op> { 3182bdd1243dSDimitry Andric defm NAME : MUBUF_Real_AllAddr_Helper_gfx80<op>; 3183bdd1243dSDimitry Andric defm _TFE : MUBUF_Real_AllAddr_Helper_gfx80<op>; 3184bdd1243dSDimitry Andric} 3185bdd1243dSDimitry Andric 31860b57cec5SDimitry Andricmulticlass MUBUF_Real_Atomic_vi<bits<7> op> : 3187bdd1243dSDimitry Andric MUBUF_Real_AllAddr_vi<op, 0> { 3188*0fca6ea1SDimitry Andric defm _OFFSET_RTN : MUBUF_Real_vi_gfx90a <op>; 3189*0fca6ea1SDimitry Andric defm _OFFEN_RTN : MUBUF_Real_vi_gfx90a <op>; 3190*0fca6ea1SDimitry Andric defm _IDXEN_RTN : MUBUF_Real_vi_gfx90a <op>; 3191*0fca6ea1SDimitry Andric defm _BOTHEN_RTN : MUBUF_Real_vi_gfx90a <op>; 31920b57cec5SDimitry Andric} 31930b57cec5SDimitry Andric 31940b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X : MUBUF_Real_AllAddr_Lds_vi <0x00>; 31950b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY : MUBUF_Real_AllAddr_vi <0x01>; 31960b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Real_AllAddr_vi <0x02>; 31970b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Real_AllAddr_vi <0x03>; 31980b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X : MUBUF_Real_AllAddr_vi <0x04>; 31990b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY : MUBUF_Real_AllAddr_vi <0x05>; 32000b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ : MUBUF_Real_AllAddr_vi <0x06>; 32010b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Real_AllAddr_vi <0x07>; 32020b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in { 32030b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_X_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x08>; 32040b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XY_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x09>; 32050b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0a>; 32060b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0b>; 32070b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_X_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0c>; 32080b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XY_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0d>; 32090b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0e>; 32100b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0f>; 32110b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 32120b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in { 32130b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Real_AllAddr_vi <0x08>; 32140b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Real_AllAddr_vi <0x09>; 32150b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_vi <0x0a>; 32160b57cec5SDimitry Andric defm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_vi <0x0b>; 32170b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_X : MUBUF_Real_AllAddr_vi <0x0c>; 32180b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Real_AllAddr_vi <0x0d>; 32190b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_vi <0x0e>; 32200b57cec5SDimitry Andric defm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_vi <0x0f>; 32210b57cec5SDimitry Andric} // End HasPackedD16VMem. 32220b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE : MUBUF_Real_AllAddr_Lds_vi <0x10>; 32230b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE : MUBUF_Real_AllAddr_Lds_vi <0x11>; 32240b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT : MUBUF_Real_AllAddr_Lds_vi <0x12>; 32250b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT : MUBUF_Real_AllAddr_Lds_vi <0x13>; 32260b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD : MUBUF_Real_AllAddr_Lds_vi <0x14>; 322781ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX2 : MUBUF_Real_AllAddr_vi <0x15>; 322881ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX3 : MUBUF_Real_AllAddr_vi <0x16>; 322981ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX4 : MUBUF_Real_AllAddr_vi <0x17>; 32300b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE : MUBUF_Real_AllAddr_vi <0x18>; 32310b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI : MUBUF_Real_AllAddr_vi <0x19>; 32320b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT : MUBUF_Real_AllAddr_vi <0x1a>; 32330b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI : MUBUF_Real_AllAddr_vi <0x1b>; 32340b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD : MUBUF_Real_AllAddr_vi <0x1c>; 32350b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2 : MUBUF_Real_AllAddr_vi <0x1d>; 32360b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3 : MUBUF_Real_AllAddr_vi <0x1e>; 32370b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4 : MUBUF_Real_AllAddr_vi <0x1f>; 32380b57cec5SDimitry Andric 32390b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16 : MUBUF_Real_AllAddr_vi <0x20>; 32400b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Real_AllAddr_vi <0x21>; 32410b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16 : MUBUF_Real_AllAddr_vi <0x22>; 32420b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Real_AllAddr_vi <0x23>; 32430b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16 : MUBUF_Real_AllAddr_vi <0x24>; 32440b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Real_AllAddr_vi <0x25>; 32450b57cec5SDimitry Andric 32460b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_vi <0x26>; 32470b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_vi <0x27>; 32480b57cec5SDimitry Andric 32490b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP : MUBUF_Real_Atomic_vi <0x40>; 32500b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP : MUBUF_Real_Atomic_vi <0x41>; 32510b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD : MUBUF_Real_Atomic_vi <0x42>; 32520b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB : MUBUF_Real_Atomic_vi <0x43>; 32530b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN : MUBUF_Real_Atomic_vi <0x44>; 32540b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN : MUBUF_Real_Atomic_vi <0x45>; 32550b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX : MUBUF_Real_Atomic_vi <0x46>; 32560b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX : MUBUF_Real_Atomic_vi <0x47>; 32570b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND : MUBUF_Real_Atomic_vi <0x48>; 32580b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR : MUBUF_Real_Atomic_vi <0x49>; 32590b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR : MUBUF_Real_Atomic_vi <0x4a>; 32600b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC : MUBUF_Real_Atomic_vi <0x4b>; 32610b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC : MUBUF_Real_Atomic_vi <0x4c>; 32620b57cec5SDimitry Andric 32630b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Real_Atomic_vi <0x60>; 32640b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Real_Atomic_vi <0x61>; 32650b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2 : MUBUF_Real_Atomic_vi <0x62>; 32660b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2 : MUBUF_Real_Atomic_vi <0x63>; 32670b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Real_Atomic_vi <0x64>; 32680b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Real_Atomic_vi <0x65>; 32690b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Real_Atomic_vi <0x66>; 32700b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Real_Atomic_vi <0x67>; 32710b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2 : MUBUF_Real_Atomic_vi <0x68>; 32720b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2 : MUBUF_Real_Atomic_vi <0x69>; 32730b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2 : MUBUF_Real_Atomic_vi <0x6a>; 32740b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2 : MUBUF_Real_Atomic_vi <0x6b>; 32750b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2 : MUBUF_Real_Atomic_vi <0x6c>; 32760b57cec5SDimitry Andric 3277*0fca6ea1SDimitry Andricdefm BUFFER_STORE_LDS_DWORD : MUBUF_Real_vi_gfx90a <0x3d>; 32780b57cec5SDimitry Andric 3279fe6060f1SDimitry Andriclet AssemblerPredicate = isGFX8GFX9 in { 3280*0fca6ea1SDimitry Andricdefm BUFFER_WBINVL1 : MUBUF_Real_vi <0x3e>; 3281*0fca6ea1SDimitry Andricdefm BUFFER_WBINVL1_VOL : MUBUF_Real_vi <0x3f>; 3282fe6060f1SDimitry Andric} // End AssemblerPredicate = isGFX8GFX9 32830b57cec5SDimitry Andric 32840b57cec5SDimitry Andric 3285fe6060f1SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Real_Atomic_vi <0x4e>; 328606c3fb27SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32 : MUBUF_Real_Atomic_vi <0x4d>; 32870b57cec5SDimitry Andric 3288fe6060f1SDimitry Andriclet SubtargetPredicate = isGFX90APlus in { 3289fe6060f1SDimitry Andric defm BUFFER_ATOMIC_ADD_F64 : MUBUF_Real_Atomic_vi<0x4f>; 3290fe6060f1SDimitry Andric defm BUFFER_ATOMIC_MIN_F64 : MUBUF_Real_Atomic_vi<0x50>; 3291fe6060f1SDimitry Andric defm BUFFER_ATOMIC_MAX_F64 : MUBUF_Real_Atomic_vi<0x51>; 3292*0fca6ea1SDimitry Andric} // End SubtargetPredicate = isGFX90APlus 3293fe6060f1SDimitry Andric 3294*0fca6ea1SDimitry Andriclet AsmString = BUFFER_WBL2.Mnemonic, // drop flags 3295*0fca6ea1SDimitry Andric AssemblerPredicate = isGFX90AOnly, 3296*0fca6ea1SDimitry Andric SubtargetPredicate = isGFX90AOnly in 3297*0fca6ea1SDimitry Andricdefm BUFFER_WBL2 : MUBUF_Real_gfx90a<0x28>; 3298*0fca6ea1SDimitry Andricdefm BUFFER_INVL2 : MUBUF_Real_gfx90a<0x29>; 3299fe6060f1SDimitry Andric 330081ad6265SDimitry Andriclet SubtargetPredicate = isGFX940Plus in { 330181ad6265SDimitry Andricdef BUFFER_WBL2_gfx940 : MUBUF_Real_gfx940<0x28, BUFFER_WBL2>; 330281ad6265SDimitry Andricdef BUFFER_INV_gfx940 : MUBUF_Real_gfx940<0x29, BUFFER_INV>; 330381ad6265SDimitry Andric} 330481ad6265SDimitry Andric 3305fe6060f1SDimitry Andricclass MTBUF_Real_Base_vi <bits<4> op, MTBUF_Pseudo ps, int Enc> : 33060b57cec5SDimitry Andric MTBUF_Real<ps>, 33070b57cec5SDimitry Andric Enc64, 3308fe6060f1SDimitry Andric SIMCInstr<ps.PseudoInstr, Enc> { 33090b57cec5SDimitry Andric 33100b57cec5SDimitry Andric let Inst{11-0} = !if(ps.has_offset, offset, ?); 33110b57cec5SDimitry Andric let Inst{12} = ps.offen; 33120b57cec5SDimitry Andric let Inst{13} = ps.idxen; 3313fe6060f1SDimitry Andric let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value); 33140b57cec5SDimitry Andric let Inst{18-15} = op; 33150b57cec5SDimitry Andric let Inst{22-19} = dfmt; 33160b57cec5SDimitry Andric let Inst{25-23} = nfmt; 33170b57cec5SDimitry Andric let Inst{31-26} = 0x3a; //encoding 33180b57cec5SDimitry Andric let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?); 3319fe6060f1SDimitry Andric let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?); 33200b57cec5SDimitry Andric let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?); 3321fe6060f1SDimitry Andric let Inst{53} = !if(ps.has_sccb, cpol{CPolBit.SCC}, ps.sccb_value); 3322fe6060f1SDimitry Andric let Inst{54} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 3323bdd1243dSDimitry Andric let Inst{55} = ps.tfe; 33240b57cec5SDimitry Andric let Inst{63-56} = !if(ps.has_soffset, soffset, ?); 33250b57cec5SDimitry Andric} 33260b57cec5SDimitry Andric 3327fe6060f1SDimitry Andricclass MTBUF_Real_vi <bits<4> op, MTBUF_Pseudo ps> : 3328fe6060f1SDimitry Andric MTBUF_Real_Base_vi <op, ps, SIEncodingFamily.VI> { 3329fe6060f1SDimitry Andric let AssemblerPredicate = isGFX8GFX9NotGFX90A; 3330fe6060f1SDimitry Andric let DecoderNamespace = "GFX8"; 3331fe6060f1SDimitry Andric 3332bdd1243dSDimitry Andric let Inst{55} = ps.tfe; 3333fe6060f1SDimitry Andric} 3334fe6060f1SDimitry Andric 3335fe6060f1SDimitry Andricclass MTBUF_Real_gfx90a <bits<4> op, MTBUF_Pseudo ps> : 3336fe6060f1SDimitry Andric MTBUF_Real_Base_vi <op, ps, SIEncodingFamily.GFX90A> { 3337fe6060f1SDimitry Andric let AssemblerPredicate = isGFX90APlus; 3338fe6060f1SDimitry Andric let DecoderNamespace = "GFX90A"; 3339bdd1243dSDimitry Andric let AsmString = ps.Mnemonic # ps.AsmOperands; 3340fe6060f1SDimitry Andric 3341fe6060f1SDimitry Andric let Inst{55} = acc; 3342fe6060f1SDimitry Andric} 3343fe6060f1SDimitry Andric 3344*0fca6ea1SDimitry Andricmulticlass MTBUF_Real_vi_gfx90a<bits<4> op> { 3345*0fca6ea1SDimitry Andric defvar ps = !cast<MTBUF_Pseudo>(NAME); 3346fe6060f1SDimitry Andric def _vi : MTBUF_Real_vi<op, ps>; 3347fe6060f1SDimitry Andric def _gfx90a : MTBUF_Real_gfx90a<op, ps>; 3348fe6060f1SDimitry Andric} 3349fe6060f1SDimitry Andric 33500b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_vi<bits<4> op> { 3351*0fca6ea1SDimitry Andric defm _OFFSET : MTBUF_Real_vi_gfx90a <op>; 3352*0fca6ea1SDimitry Andric defm _OFFEN : MTBUF_Real_vi_gfx90a <op>; 3353*0fca6ea1SDimitry Andric defm _IDXEN : MTBUF_Real_vi_gfx90a <op>; 3354*0fca6ea1SDimitry Andric defm _BOTHEN : MTBUF_Real_vi_gfx90a <op>; 33550b57cec5SDimitry Andric} 33560b57cec5SDimitry Andric 3357*0fca6ea1SDimitry Andricmulticlass MTBUF_Real_gfx80 <bits<4> op> { 3358*0fca6ea1SDimitry Andric defvar ps = !cast<MTBUF_Pseudo>(NAME); 3359*0fca6ea1SDimitry Andric def _gfx80 : MTBUF_Real<ps>, 33600b57cec5SDimitry Andric Enc64, 33610b57cec5SDimitry Andric SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> { 33620b57cec5SDimitry Andric let AssemblerPredicate=HasUnpackedD16VMem; 33630b57cec5SDimitry Andric let DecoderNamespace="GFX80_UNPACKED"; 33640b57cec5SDimitry Andric 33650b57cec5SDimitry Andric let Inst{11-0} = !if(ps.has_offset, offset, ?); 33660b57cec5SDimitry Andric let Inst{12} = ps.offen; 33670b57cec5SDimitry Andric let Inst{13} = ps.idxen; 3368fe6060f1SDimitry Andric let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value); 33690b57cec5SDimitry Andric let Inst{18-15} = op; 33700b57cec5SDimitry Andric let Inst{22-19} = dfmt; 33710b57cec5SDimitry Andric let Inst{25-23} = nfmt; 33720b57cec5SDimitry Andric let Inst{31-26} = 0x3a; //encoding 33730b57cec5SDimitry Andric let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?); 3374fe6060f1SDimitry Andric let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?); 33750b57cec5SDimitry Andric let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?); 3376fe6060f1SDimitry Andric let Inst{54} = !if(ps.has_slc, cpol{CPolBit.SLC}, ?); 3377bdd1243dSDimitry Andric let Inst{55} = ps.tfe; 33780b57cec5SDimitry Andric let Inst{63-56} = !if(ps.has_soffset, soffset, ?); 33790b57cec5SDimitry Andric } 3380*0fca6ea1SDimitry Andric} 33810b57cec5SDimitry Andric 33820b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx80<bits<4> op> { 3383*0fca6ea1SDimitry Andric defm _OFFSET : MTBUF_Real_gfx80 <op>; 3384*0fca6ea1SDimitry Andric defm _OFFEN : MTBUF_Real_gfx80 <op>; 3385*0fca6ea1SDimitry Andric defm _IDXEN : MTBUF_Real_gfx80 <op>; 3386*0fca6ea1SDimitry Andric defm _BOTHEN : MTBUF_Real_gfx80 <op>; 33870b57cec5SDimitry Andric} 33880b57cec5SDimitry Andric 33890b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X : MTBUF_Real_AllAddr_vi <0x00>; 33900b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY : MTBUF_Real_AllAddr_vi <0x01>; 33910b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ : MTBUF_Real_AllAddr_vi <0x02>; 33920b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Real_AllAddr_vi <0x03>; 33930b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_X : MTBUF_Real_AllAddr_vi <0x04>; 33940b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY : MTBUF_Real_AllAddr_vi <0x05>; 33950b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Real_AllAddr_vi <0x06>; 33960b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_vi <0x07>; 33970b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in { 33980b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_X_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x08>; 33990b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x09>; 34000b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0a>; 34010b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0b>; 34020b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_X_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0c>; 34030b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XY_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0d>; 34040b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0e>; 34050b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0f>; 34060b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 34070b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in { 34080b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_X : MTBUF_Real_AllAddr_vi <0x08>; 34090b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XY : MTBUF_Real_AllAddr_vi <0x09>; 34100b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_vi <0x0a>; 34110b57cec5SDimitry Andric defm TBUFFER_LOAD_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_vi <0x0b>; 34120b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_X : MTBUF_Real_AllAddr_vi <0x0c>; 34130b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XY : MTBUF_Real_AllAddr_vi <0x0d>; 34140b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_vi <0x0e>; 34150b57cec5SDimitry Andric defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_vi <0x0f>; 34160b57cec5SDimitry Andric} // End HasUnpackedD16VMem. 34170b57cec5SDimitry Andric 34180b57cec5SDimitry Andricdef MUBUFInfoTable : GenericTable { 34190b57cec5SDimitry Andric let FilterClass = "MUBUF_Pseudo"; 34200b57cec5SDimitry Andric let CppTypeName = "MUBUFInfo"; 3421fe6060f1SDimitry Andric let Fields = [ 3422fe6060f1SDimitry Andric "Opcode", "BaseOpcode", "elements", "has_vaddr", "has_srsrc", "has_soffset", 3423*0fca6ea1SDimitry Andric "IsBufferInv", "tfe" 3424fe6060f1SDimitry Andric ]; 34250b57cec5SDimitry Andric 34260b57cec5SDimitry Andric let PrimaryKey = ["Opcode"]; 34270b57cec5SDimitry Andric let PrimaryKeyName = "getMUBUFOpcodeHelper"; 34280b57cec5SDimitry Andric} 34290b57cec5SDimitry Andric 34300b57cec5SDimitry Andricdef getMUBUFInfoFromOpcode : SearchIndex { 34310b57cec5SDimitry Andric let Table = MUBUFInfoTable; 34320b57cec5SDimitry Andric let Key = ["Opcode"]; 34330b57cec5SDimitry Andric} 34340b57cec5SDimitry Andric 34358bcb0991SDimitry Andricdef getMUBUFInfoFromBaseOpcodeAndElements : SearchIndex { 34360b57cec5SDimitry Andric let Table = MUBUFInfoTable; 34378bcb0991SDimitry Andric let Key = ["BaseOpcode", "elements"]; 34388bcb0991SDimitry Andric} 34398bcb0991SDimitry Andric 34408bcb0991SDimitry Andricdef MTBUFInfoTable : GenericTable { 34418bcb0991SDimitry Andric let FilterClass = "MTBUF_Pseudo"; 34428bcb0991SDimitry Andric let CppTypeName = "MTBUFInfo"; 34438bcb0991SDimitry Andric let Fields = ["Opcode", "BaseOpcode", "elements", "has_vaddr", "has_srsrc", "has_soffset"]; 34448bcb0991SDimitry Andric 34458bcb0991SDimitry Andric let PrimaryKey = ["Opcode"]; 34468bcb0991SDimitry Andric let PrimaryKeyName = "getMTBUFOpcodeHelper"; 34478bcb0991SDimitry Andric} 34488bcb0991SDimitry Andric 34498bcb0991SDimitry Andricdef getMTBUFInfoFromOpcode : SearchIndex { 34508bcb0991SDimitry Andric let Table = MTBUFInfoTable; 34518bcb0991SDimitry Andric let Key = ["Opcode"]; 34528bcb0991SDimitry Andric} 34538bcb0991SDimitry Andric 34548bcb0991SDimitry Andricdef getMTBUFInfoFromBaseOpcodeAndElements : SearchIndex { 34558bcb0991SDimitry Andric let Table = MTBUFInfoTable; 34568bcb0991SDimitry Andric let Key = ["BaseOpcode", "elements"]; 34570b57cec5SDimitry Andric} 3458