[AMDGPU][AsmParser][NFC] Generate printers for named-bit operands automatically.
Part of <https://github.com/llvm/llvm-project/issues/62629>. Reviewed By: foad Differential Revision: https://reviews.llvm.org/D154433
This commit is contained in:
parent
12460cf90f
commit
7208fde09e
@ -100,21 +100,6 @@ void AMDGPUInstPrinter::printNamedBit(const MCInst *MI, unsigned OpNo,
|
||||
}
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printOffen(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "offen");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printIdxen(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "idxen");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printAddr64(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "addr64");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printOffset(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
@ -186,11 +171,6 @@ void AMDGPUInstPrinter::printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo,
|
||||
printU32ImmOperand(MI, OpNo, STI, O);
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printGDS(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "gds");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printCPol(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
auto Imm = MI->getOperand(OpNo).getImm();
|
||||
@ -208,11 +188,6 @@ void AMDGPUInstPrinter::printCPol(const MCInst *MI, unsigned OpNo,
|
||||
O << " /* unexpected cache policy bit */";
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printTFE(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "tfe");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printDMask(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
if (MI->getOperand(OpNo).getImm()) {
|
||||
@ -233,16 +208,6 @@ void AMDGPUInstPrinter::printDim(const MCInst *MI, unsigned OpNo,
|
||||
O << Dim;
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printUNorm(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "unorm");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printDA(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "da");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printR128A16(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
if (STI.hasFeature(AMDGPU::FeatureR128A16))
|
||||
@ -251,33 +216,6 @@ void AMDGPUInstPrinter::printR128A16(const MCInst *MI, unsigned OpNo,
|
||||
printNamedBit(MI, OpNo, O, "r128");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printA16(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "a16");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printLWE(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "lwe");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printD16(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "d16");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printExpCompr(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "compr");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printExpVM(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "vm");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printFORMAT(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
@ -1324,18 +1262,6 @@ void AMDGPUInstPrinter::printIfSet(const MCInst *MI, unsigned OpNo,
|
||||
O << Asm;
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printHigh(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "high");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printClampSI(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
printNamedBit(MI, OpNo, O, "clamp");
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printOModSI(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
|
||||
@ -47,9 +47,6 @@ private:
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printNamedBit(const MCInst *MI, unsigned OpNo, raw_ostream &O,
|
||||
StringRef BitName);
|
||||
void printOffen(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printIdxen(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printAddr64(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printFlatOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
@ -67,32 +64,14 @@ private:
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printGDS(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printCPol(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,
|
||||
raw_ostream &O);
|
||||
void printDim(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printUNorm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printDA(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printR128A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printA16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printLWE(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printD16(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printExpCompr(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printExpVM(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printFORMAT(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printSymbolicFormat(const MCInst *MI,
|
||||
@ -202,12 +181,8 @@ public:
|
||||
protected:
|
||||
void printAbs(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printHigh(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printClamp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printClampSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
raw_ostream &O);
|
||||
void printLiteral(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
||||
|
||||
@ -1047,12 +1047,16 @@ class NamedBitOperand<string Id, string Name = NAME>
|
||||
let ParserMethod =
|
||||
"[this](OperandVector &Operands) -> ParseStatus { "#
|
||||
"return parseNamedBit(\""#Id#"\", Operands, AMDGPUOperand::"#ImmTy#"); }";
|
||||
let PrintMethod = "[this](const MCInst *MI, unsigned OpNo, "#
|
||||
"const MCSubtargetInfo &STI, raw_ostream &O) { "#
|
||||
"printNamedBit(MI, OpNo, O, \""#Id#"\"); }";
|
||||
}
|
||||
|
||||
class DefaultOperand<CustomOperand Op, int Value>
|
||||
: OperandWithDefaultOps<Op.Type, (ops (Op.Type Value))>,
|
||||
CustomOperandProps<1, Op.ParserMatchClass.Name> {
|
||||
let ParserMethod = Op.ParserMatchClass.ParserMethod;
|
||||
let PrintMethod = Op.PrintMethod;
|
||||
}
|
||||
|
||||
class SDWAOperand<string Id, string Name = NAME>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user