[AMDGPU][AsmParser] Simplify the implementation of SWZ operands.
Those are implicit helper operands and therefore don't need any parsers or printers. Part of <https://github.com/llvm/llvm-project/issues/62629>. Reviewed By: piotr, foad Differential Revision: https://reviews.llvm.org/D154432
This commit is contained in:
parent
dac5957ca9
commit
12460cf90f
@ -123,6 +123,8 @@ def FMA : Predicate<"Subtarget->hasFMA()">;
|
||||
|
||||
def InstFlag : OperandWithDefaultOps <i32, (ops (i32 0))>;
|
||||
|
||||
def i1imm_0 : OperandWithDefaultOps<i1, (ops (i1 0))>;
|
||||
|
||||
class CustomOperandClass<string name, bit optional, string parserMethod,
|
||||
string defaultMethod>
|
||||
: AsmOperandClass {
|
||||
|
||||
@ -121,7 +121,6 @@ public:
|
||||
ImmTyOffset1,
|
||||
ImmTySMEMOffsetMod,
|
||||
ImmTyCPol,
|
||||
ImmTySWZ,
|
||||
ImmTyTFE,
|
||||
ImmTyD16,
|
||||
ImmTyClampSI,
|
||||
@ -378,7 +377,6 @@ public:
|
||||
bool isGDS() const { return isImmTy(ImmTyGDS); }
|
||||
bool isLDS() const { return isImmTy(ImmTyLDS); }
|
||||
bool isCPol() const { return isImmTy(ImmTyCPol); }
|
||||
bool isSWZ() const { return isImmTy(ImmTySWZ); }
|
||||
bool isTFE() const { return isImmTy(ImmTyTFE); }
|
||||
bool isD16() const { return isImmTy(ImmTyD16); }
|
||||
bool isFORMAT() const { return isImmTy(ImmTyFORMAT) && isUInt<7>(getImm()); }
|
||||
@ -1009,7 +1007,6 @@ public:
|
||||
case ImmTyOffset1: OS << "Offset1"; break;
|
||||
case ImmTySMEMOffsetMod: OS << "SMEMOffsetMod"; break;
|
||||
case ImmTyCPol: OS << "CPol"; break;
|
||||
case ImmTySWZ: OS << "SWZ"; break;
|
||||
case ImmTyTFE: OS << "TFE"; break;
|
||||
case ImmTyD16: OS << "D16"; break;
|
||||
case ImmTyFORMAT: OS << "FORMAT"; break;
|
||||
@ -7650,7 +7647,6 @@ void AMDGPUAsmParser::cvtMubufImpl(MCInst &Inst,
|
||||
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTyOffset);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTyCPol, 0);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySWZ);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@ -157,7 +157,7 @@ class getMTBUFInsDA<list<RegisterClass> vdataList,
|
||||
RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
|
||||
RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret;
|
||||
|
||||
dag NonVaddrInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, FORMAT:$format, CPol:$cpol, SWZ:$swz);
|
||||
dag NonVaddrInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, FORMAT:$format, CPol:$cpol, i1imm:$swz);
|
||||
dag Inputs = !if(!empty(vaddrList), NonVaddrInputs, !con((ins vaddrClass:$vaddr), NonVaddrInputs));
|
||||
dag ret = !if(!empty(vdataList), Inputs, !con((ins vdata_op:$vdata), Inputs));
|
||||
}
|
||||
@ -185,7 +185,7 @@ class getMTBUFAsmOps<int addrKind> {
|
||||
!if(!eq(addrKind, BUFAddrKind.Addr64),
|
||||
"$vaddr, $srsrc,$format $soffset addr64",
|
||||
"")))));
|
||||
string ret = " $vdata, " # Pfx # "$offset$cpol$swz";
|
||||
string ret = " $vdata, " # Pfx # "$offset$cpol";
|
||||
}
|
||||
|
||||
class MTBUF_SetupAddr<int addrKind> {
|
||||
@ -386,7 +386,7 @@ class getMUBUFInsDA<list<RegisterClass> vdataList,
|
||||
RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
|
||||
RegisterOperand vdata_op = getLdStVDataRegisterOperand<vdataClass, isTFE>.ret;
|
||||
|
||||
dag NonVaddrInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, CPol_0:$cpol, SWZ_0:$swz);
|
||||
dag NonVaddrInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, CPol_0:$cpol, i1imm_0:$swz);
|
||||
dag Inputs = !if(!empty(vaddrList), NonVaddrInputs, !con((ins vaddrClass:$vaddr), NonVaddrInputs));
|
||||
dag ret = !if(!empty(vdataList), Inputs, !con((ins vdata_op:$vdata), Inputs));
|
||||
}
|
||||
@ -420,7 +420,7 @@ class getMUBUFIns<int addrKind, list<RegisterClass> vdataList, bit isTFE> {
|
||||
(ins))))));
|
||||
}
|
||||
|
||||
class getMUBUFAsmOps<int addrKind, bit noVdata = 0, bit isLds = 0, bit isTFE = 0, bit isSwz = 0> {
|
||||
class getMUBUFAsmOps<int addrKind, bit noVdata = 0, bit isLds = 0, bit isTFE = 0> {
|
||||
string Vdata = !if(noVdata, " ", " $vdata, ");
|
||||
string Lds = !if(isLds, " lds", "");
|
||||
string TFE = !if(isTFE, " tfe", "");
|
||||
@ -433,9 +433,8 @@ class getMUBUFAsmOps<int addrKind, bit noVdata = 0, bit isLds = 0, bit isTFE = 0
|
||||
"")))));
|
||||
string Offset = "$offset";
|
||||
string OtherArgs = "$cpol";
|
||||
string Swz = !if(isSwz, "$swz", "");
|
||||
|
||||
string ret = Vdata # MainArgs # Offset # OtherArgs # Lds # TFE # Swz;
|
||||
string ret = Vdata # MainArgs # Offset # OtherArgs # Lds # TFE;
|
||||
}
|
||||
|
||||
class MUBUF_SetupAddr<int addrKind> {
|
||||
@ -466,7 +465,7 @@ class MUBUF_Load_Pseudo <string opName,
|
||||
!if(!or(isLds, isLdsOpc), (outs), (outs vdata_op:$vdata)),
|
||||
!con(getMUBUFIns<addrKindCopy, [], isTFE>.ret,
|
||||
!if(HasTiedDest, (ins vdata_op:$vdata_in), (ins))),
|
||||
getMUBUFAsmOps<addrKindCopy, !or(isLds, isLdsOpc), isLds, isTFE, 1>.ret,
|
||||
getMUBUFAsmOps<addrKindCopy, !or(isLds, isLdsOpc), isLds, isTFE>.ret,
|
||||
pattern>,
|
||||
MUBUF_SetupAddr<addrKindCopy> {
|
||||
let PseudoInstr = opName # !if(isLds, "_lds", "") # !if(isTFE, "_tfe", "") #
|
||||
@ -561,7 +560,7 @@ class MUBUF_Store_Pseudo <string opName,
|
||||
: MUBUF_Pseudo<opName,
|
||||
(outs),
|
||||
getMUBUFIns<addrKindCopy, [getVregSrcForVT<store_vt>.ret], isTFE>.ret,
|
||||
getMUBUFAsmOps<addrKindCopy, 0, 0, isTFE, 1>.ret,
|
||||
getMUBUFAsmOps<addrKindCopy, 0, 0, isTFE>.ret,
|
||||
pattern>,
|
||||
MUBUF_SetupAddr<addrKindCopy> {
|
||||
let PseudoInstr = opName # "_" # !if(isTFE, "_tfe", "") #
|
||||
@ -608,8 +607,8 @@ multiclass MUBUF_Pseudo_Stores<string opName, ValueType store_vt = i32,
|
||||
class MUBUF_Pseudo_Store_Lds<string opName>
|
||||
: MUBUF_Pseudo<opName,
|
||||
(outs),
|
||||
(ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, CPol:$cpol, SWZ:$swz),
|
||||
" $srsrc, $soffset$offset lds$cpol$swz"> {
|
||||
(ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, CPol:$cpol, i1imm:$swz),
|
||||
" $srsrc, $soffset$offset lds$cpol"> {
|
||||
let LGKM_CNT = 1;
|
||||
let mayLoad = 1;
|
||||
let mayStore = 1;
|
||||
|
||||
@ -208,10 +208,6 @@ void AMDGPUInstPrinter::printCPol(const MCInst *MI, unsigned OpNo,
|
||||
O << " /* unexpected cache policy bit */";
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printSWZ(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printTFE(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "tfe");
|
||||
|
||||
@ -71,8 +71,6 @@ private:
|
||||
raw_ostream &O);
|
||||
void printCPol(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printSWZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printTFE(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printDMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
|
||||
@ -1094,8 +1094,6 @@ def CPol_0 : DefaultOperand<CPol, 0>;
|
||||
def CPol_GLC1 : DefaultOperand<CPol, 1>;
|
||||
|
||||
def TFE : NamedBitOperand<"tfe">;
|
||||
def SWZ : NamedBitOperand<"swz">;
|
||||
def SWZ_0 : DefaultOperand<SWZ, 0>;
|
||||
def UNorm : NamedBitOperand<"unorm">;
|
||||
def DA : NamedBitOperand<"da">;
|
||||
def R128A16 : CustomOperand<i1, 1>;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user