[RISCV] Use inheritance to reduce some repeated code in tablegen. NFC
authorCraig Topper <craig.topper@sifive.com>
Fri, 19 Feb 2021 18:36:26 +0000 (10:36 -0800)
committerCraig Topper <craig.topper@sifive.com>
Fri, 19 Feb 2021 18:42:18 +0000 (10:42 -0800)
The VLX and VSX searchable tables, share the same format so we
can have a common base class for them.

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

index df4b219..5d70266 100644 (file)
@@ -413,7 +413,7 @@ def RISCVVIntrinsicsTable : GenericTable {
   let PrimaryKeyName = "getRISCVVIntrinsicInfo";
 }
 
-class RISCVVLX<bit M, bit O, bits<7> S, bits<3> L, bits<3> IL> {
+class RISCVVLX_VSX<bit M, bit O, bits<7> S, bits<3> L, bits<3> IL> {
   bits<1> Masked = M;
   bits<1> Ordered = O;
   bits<7> SEW = S;
@@ -422,28 +422,24 @@ class RISCVVLX<bit M, bit O, bits<7> S, bits<3> L, bits<3> IL> {
   Pseudo Pseudo = !cast<Pseudo>(NAME);
 }
 
-def RISCVVLXTable : GenericTable {
-  let FilterClass = "RISCVVLX";
+class RISCVVLX<bit M, bit O, bits<7> S, bits<3> L, bits<3> IL> :
+  RISCVVLX_VSX<M, O, S, L, IL>;
+class RISCVVSX<bit M, bit O, bits<7> S, bits<3> L, bits<3> IL> :
+  RISCVVLX_VSX<M, O, S, L, IL>;
+
+class RISCVVLX_VSXTable : GenericTable {
   let CppTypeName = "VLX_VSXPseudo";
   let Fields = ["Masked", "Ordered", "SEW", "LMUL", "IndexLMUL", "Pseudo"];
   let PrimaryKey = ["Masked", "Ordered", "SEW", "LMUL", "IndexLMUL"];
-  let PrimaryKeyName = "getVLXPseudo";
 }
 
-class RISCVVSX<bit M, bit O, bits<7> S, bits<3> L, bits<3> IL> {
-  bits<1> Masked = M;
-  bits<1> Ordered = O;
-  bits<7> SEW = S;
-  bits<3> LMUL = L;
-  bits<3> IndexLMUL = IL;
-  Pseudo Pseudo = !cast<Pseudo>(NAME);
+def RISCVVLXTable : RISCVVLX_VSXTable {
+  let FilterClass = "RISCVVLX";
+  let PrimaryKeyName = "getVLXPseudo";
 }
 
-def RISCVVSXTable : GenericTable {
+def RISCVVSXTable : RISCVVLX_VSXTable {
   let FilterClass = "RISCVVSX";
-  let CppTypeName = "VLX_VSXPseudo";
-  let Fields = ["Masked", "Ordered", "SEW", "LMUL", "IndexLMUL", "Pseudo"];
-  let PrimaryKey = ["Masked", "Ordered", "SEW", "LMUL", "IndexLMUL"];
   let PrimaryKeyName = "getVSXPseudo";
 }