khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Remove MaskedPrototype and add several fields in RVVIntrinsicRecord,
compute Prototype in runtime.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126741

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRVVLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===================================================================
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -50,9 +50,6 @@
   // Prototype for this intrinsic.
   SmallVector<PrototypeDescriptor> Prototype;
 
-  // Prototype for masked intrinsic.
-  SmallVector<PrototypeDescriptor> MaskedPrototype;
-
   // Suffix of intrinsic name.
   SmallVector<PrototypeDescriptor> Suffix;
 
@@ -61,6 +58,10 @@
 
   // Number of field, large than 1 if it's segment load/store.
   unsigned NF;
+
+  bool HasMasked :1;
+  bool HasVL :1;
+  bool HasMaskedOffOperand :1;
 };
 
 class RVVEmitter {
@@ -478,11 +479,11 @@
     }
 
     SR.NF = NF;
+    SR.HasMasked = HasMasked;
+    SR.HasVL = HasVL;
+    SR.HasMaskedOffOperand = HasMaskedOffOperand;
 
-    SR.Prototype = std::move(Prototype);
-
-    if (HasMasked)
-      SR.MaskedPrototype = std::move(MaskedPrototype);
+    SR.Prototype = std::move(BasicPrototype);
 
     auto InitSuffixtype = [&](SmallVectorImpl<PrototypeDescriptor> &PS,
                               StringRef Prototypes) {
@@ -566,7 +567,6 @@
 
   for (const auto &SemaRecord : SemaRecords) {
     InsertToSignatureSet(SemaRecord.Prototype);
-    InsertToSignatureSet(SemaRecord.MaskedPrototype);
     InsertToSignatureSet(SemaRecord.Suffix);
     InsertToSignatureSet(SemaRecord.OverloadedSuffix);
   }
@@ -585,17 +585,18 @@
     Record.Name = SR.Name.c_str();
     Record.OverloadedName = SR.OverloadedName.c_str();
     Record.PrototypeIndex = GetSemaSignatureIndex(SR.Prototype);
-    Record.MaskedPrototypeIndex = GetSemaSignatureIndex(SR.MaskedPrototype);
     Record.SuffixIndex = GetSemaSignatureIndex(SR.Suffix);
     Record.OverloadedSuffixIndex = GetSemaSignatureIndex(SR.OverloadedSuffix);
     Record.PrototypeLength = SR.Prototype.size();
-    Record.MaskedPrototypeLength = SR.MaskedPrototype.size();
     Record.SuffixLength = SR.Suffix.size();
     Record.OverloadedSuffixSize = SR.OverloadedSuffix.size();
     Record.RequiredExtension = SR.RequiredExtension;
     Record.TypeRangeMask = SR.TypeRangeMask;
     Record.Log2LMULMask = SR.Log2LMULMask;
     Record.NF = SR.NF;
+    Record.HasMasked = SR.HasMasked;
+    Record.HasVL = SR.HasVL;
+    Record.HasMaskedOffOperand = SR.HasMaskedOffOperand;
     Out.push_back(Record);
   }
 }
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===================================================================
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -983,17 +983,18 @@
   else
     OS << "\"" << Record.OverloadedName << "\",";
   OS << Record.PrototypeIndex << ",";
-  OS << Record.MaskedPrototypeIndex << ",";
   OS << Record.SuffixIndex << ",";
   OS << Record.OverloadedSuffixIndex << ",";
   OS << (int)Record.PrototypeLength << ",";
-  OS << (int)Record.MaskedPrototypeLength << ",";
   OS << (int)Record.SuffixLength << ",";
   OS << (int)Record.OverloadedSuffixSize << ",";
   OS << (int)Record.RequiredExtension << ",";
   OS << (int)Record.TypeRangeMask << ",";
   OS << (int)Record.Log2LMULMask << ",";
   OS << (int)Record.NF << ",";
+  OS << (int)Record.HasMasked << ",";
+  OS << (int)Record.HasVL << ",";
+  OS << (int)Record.HasMaskedOffOperand << ",";
   OS << "},\n";
   return OS;
 }
Index: clang/lib/Sema/SemaRVVLookup.cpp
===================================================================
--- clang/lib/Sema/SemaRVVLookup.cpp
+++ clang/lib/Sema/SemaRVVLookup.cpp
@@ -174,10 +174,17 @@
   for (auto &Record : RVVIntrinsicRecords) {
     // Create Intrinsics for each type and LMUL.
     BasicType BaseType = BasicType::Unknown;
-    auto ProtoSeq =
+    auto BasicProtoSeq =
         ProtoSeq2ArrayRef(Record.PrototypeIndex, Record.PrototypeLength);
-    auto ProtoMaskSeq = ProtoSeq2ArrayRef(Record.MaskedPrototypeIndex,
-                                          Record.MaskedPrototypeLength);
+
+    auto ProtoSeq = RVVIntrinsic::computeBuiltinTypes(
+        BasicProtoSeq, /*IsMasked=*/false,
+        /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF);
+
+    auto ProtoMaskSeq = RVVIntrinsic::computeBuiltinTypes(
+        BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand,
+        Record.HasVL, Record.NF);
+
     auto SuffixProto =
         ProtoSeq2ArrayRef(Record.SuffixIndex, Record.SuffixLength);
     auto MangledSuffixProto = ProtoSeq2ArrayRef(Record.OverloadedSuffixIndex,
@@ -232,9 +239,7 @@
         // Create non-masked intrinsic.
         InitRVVIntrinsic(Record, SuffixStr, OverloadedSuffixStr, false, *Types);
 
-        bool HasMask = Record.MaskedPrototypeLength != 0;
-
-        if (HasMask) {
+        if (Record.HasMasked) {
           // Create masked intrinsic.
           Optional<RVVTypes> MaskTypes = RVVType::computeTypes(
               BaseType, Log2LMUL, Record.NF, ProtoMaskSeq);
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===================================================================
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -366,9 +366,6 @@
   // Prototype for this intrinsic, index of RVVSignatureTable.
   uint16_t PrototypeIndex;
 
-  // Prototype for masked intrinsic, index of RVVSignatureTable.
-  uint16_t MaskedPrototypeIndex;
-
   // Suffix of intrinsic name, index of RVVSignatureTable.
   uint16_t SuffixIndex;
 
@@ -378,9 +375,6 @@
   // Length of the prototype.
   uint8_t PrototypeLength;
 
-  // Length of prototype of masked intrinsic.
-  uint8_t MaskedPrototypeLength;
-
   // Length of intrinsic name suffix.
   uint8_t SuffixLength;
 
@@ -398,6 +392,10 @@
 
   // Number of field, large than 1 if it's segment load/store.
   uint8_t NF;
+
+  bool HasMasked : 1;
+  bool HasVL : 1;
+  bool HasMaskedOffOperand : 1;
 };
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D126741: [RISC... Zakk Chen via Phabricator via cfe-commits

Reply via email to