[PATCH] D151684: [AMDGPU][AsmParser][NFC] Immediate operand classes to derive from custom operands.
Ivan Kosarev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 29 23:40:09 PDT 2023
kosarev created this revision.
Herald added subscribers: foad, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
kosarev requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Removes unnecessary duplication in TableGen definitions.
Part of https://github.com/llvm/llvm-project/issues/62629.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151684
Files:
llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
llvm/lib/Target/AMDGPU/SIInstrInfo.td
Index: llvm/lib/Target/AMDGPU/SIInstrInfo.td
===================================================================
--- llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -1121,26 +1121,6 @@
let PrintMethod = "printVOPDst";
}
-class CustomOperandClass<string CName, bit Optional> : AsmOperandClass {
- let Name = CName;
- let PredicateMethod = "is"#CName;
- let ParserMethod = "parse"#CName;
- let RenderMethod = "addImmOperands";
- let IsOptional = Optional;
- let DefaultMethod = "default"#CName;
-}
-
-class CustomOperandProps<bit Optional = 0, string Name = NAME,
- AsmOperandClass Class = CustomOperandClass<Name, Optional>> {
- string PrintMethod = "print"#Name;
- AsmOperandClass ParserMatchClass = Class;
- string OperandType = "OPERAND_IMMEDIATE";
-}
-
-class CustomOperand<ValueType Type, bit Optional = 0, string Name = NAME,
- AsmOperandClass Class = CustomOperandClass<Name, Optional>>
- : Operand<Type>, CustomOperandProps<Optional, Name, Class>;
-
class NamedIntOperandClass<string Prefix, string Name, string ConvertMethod>
: CustomOperandClass<Name, 1> {
string ImmTy = "AMDGPUOperand::ImmTy"#Name;
Index: llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
+++ llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
@@ -123,20 +123,35 @@
def InstFlag : OperandWithDefaultOps <i32, (ops (i32 0))>;
-class ImmOperandClass<string name, bit optional> : AsmOperandClass {
+class CustomOperandClass<string name, bit optional> : AsmOperandClass {
let Name = name;
let PredicateMethod = "is"#name;
- let ParserMethod = "";
+ let ParserMethod = "parse"#name;
let RenderMethod = "addImmOperands";
let IsOptional = optional;
let DefaultMethod = "default"#name;
}
+class CustomOperandProps<bit optional = 0, string name = NAME,
+ AsmOperandClass opClass = CustomOperandClass<name, optional>> {
+ string PrintMethod = "print"#name;
+ AsmOperandClass ParserMatchClass = opClass;
+ string OperandType = "OPERAND_IMMEDIATE";
+}
+
+class CustomOperand<ValueType type, bit optional = 0, string name = NAME,
+ AsmOperandClass opClass = CustomOperandClass<name, optional>>
+ : Operand<type>, CustomOperandProps<optional, name, opClass>;
+
+class ImmOperandClass<string name, bit optional>
+ : CustomOperandClass<name, optional> {
+ let ParserMethod = "";
+}
+
class ImmOperand<ValueType type, string name, bit optional = 0,
- string printer = "print"#name> : Operand<type> {
- let ParserMatchClass = ImmOperandClass<name, optional>;
+ string printer = "print"#name>
+ : CustomOperand<type, optional, name, ImmOperandClass<name, optional>> {
let PrintMethod = printer;
- let OperandType = "OPERAND_IMMEDIATE";
}
def s16imm : ImmOperand<i16, "S16Imm", 0, "printU16ImmOperand">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151684.526521.patch
Type: text/x-patch
Size: 2918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230530/493ec3ae/attachment.bin>
More information about the llvm-commits
mailing list