[llvm] [RISCV] Specify FilterClassField to filter out unneeded pseudos (PR #65460)

Wang Pengcheng via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 19:41:50 PDT 2023


https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/65460:

>From 660824e63f6d40f8370e88921c48aa82fbf1701f Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Wed, 6 Sep 2023 17:16:23 +0800
Subject: [PATCH 1/2] [RISCV] Specify FilterClassField to filter out unneeded
 pseudos

`VMCLR` and `VMSET` will be expanded before MC emitting, so we
don't need them being in RISCVVPseudosTable.
---
 llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index c3f2f1035bb7471..2348b78e2a8339b 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -527,11 +527,17 @@ class RISCVVPseudo {
   Instruction BaseInstr = !cast<Instruction>(PseudoToVInst<NAME>.VInst);
   // SEW = 0 is used to denote that the Pseudo is not SEW specific (or unknown).
   bits<8> SEW = 0;
+  bit IsNeeded = !cond(
+    !ne(!find(NAME, "PseudoVMCLR"), -1): 0,
+    !ne(!find(NAME, "PseudoVMSET"), -1): 0,
+    true: 1
+  );
 }
 
 // The actual table.
 def RISCVVPseudosTable : GenericTable {
   let FilterClass = "RISCVVPseudo";
+  let FilterClassField = "IsNeeded";
   let CppTypeName = "PseudoInfo";
   let Fields = [ "Pseudo", "BaseInstr" ];
   let PrimaryKey = [ "Pseudo" ];

>From 12dd76ab2753c2c91cc646277bf112abc7651b5d Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Thu, 7 Sep 2023 10:53:17 +0800
Subject: [PATCH 2/2] fixup! [RISCV] Specify FilterClassField to filter out
 unneeded pseudos

---
 llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 2348b78e2a8339b..233f06ddb479777 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -527,17 +527,13 @@ class RISCVVPseudo {
   Instruction BaseInstr = !cast<Instruction>(PseudoToVInst<NAME>.VInst);
   // SEW = 0 is used to denote that the Pseudo is not SEW specific (or unknown).
   bits<8> SEW = 0;
-  bit IsNeeded = !cond(
-    !ne(!find(NAME, "PseudoVMCLR"), -1): 0,
-    !ne(!find(NAME, "PseudoVMSET"), -1): 0,
-    true: 1
-  );
+  bit NeedBeInPseudoTable = 1;
 }
 
 // The actual table.
 def RISCVVPseudosTable : GenericTable {
   let FilterClass = "RISCVVPseudo";
-  let FilterClassField = "IsNeeded";
+  let FilterClassField = "NeedBeInPseudoTable";
   let CppTypeName = "PseudoInfo";
   let Fields = [ "Pseudo", "BaseInstr" ];
   let PrimaryKey = [ "Pseudo" ];
@@ -1004,6 +1000,8 @@ class VPseudoNullaryPseudoM<string BaseInst> :
   // BaseInstr is not used in RISCVExpandPseudoInsts pass.
   // Just fill a corresponding real v-inst to pass tablegen check.
   let BaseInstr = !cast<Instruction>(BaseInst);
+  // We exclude them from RISCVVPseudoTable.
+  let NeedBeInPseudoTable = 0;
 }
 
 class VPseudoUnaryNoMask<DAGOperand RetClass,



More information about the llvm-commits mailing list