[15/15][Clang][RISCV][NFC] Set data member under Policy as constants
authoreopXD <yueh.ting.chen@gmail.com>
Sun, 15 Jan 2023 17:56:23 +0000 (09:56 -0800)
committereopXD <yueh.ting.chen@gmail.com>
Tue, 24 Jan 2023 16:38:10 +0000 (08:38 -0800)
The object is now correct by construction.

This is the 15th commit of a patch-set that aims to change the default policy
for RVV intrinsics from TAMU to TAMA.

Please refer to the cover letter in the 1st commit (D141573) for an
overview.

Depends on D141793.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D141796

clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Support/RISCVVIntrinsicUtils.cpp

index fc53d70..1ae7428 100644 (file)
@@ -92,15 +92,22 @@ enum class TypeModifier : uint8_t {
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
     Undisturbed,
     Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+
+private:
+  const bool IsUnspecified = false;
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
       : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
         HasMaskPolicy(HasMaskPolicy) {}
@@ -422,7 +429,6 @@ public:
     return IntrinsicTypes;
   }
   Policy getPolicyAttrs() const {
-    assert(PolicyAttrs.IsUnspecified == false);
     return PolicyAttrs;
   }
   unsigned getPolicyAttrsBits() const {
@@ -431,8 +437,6 @@ public:
     // The 1st bit simulates the `vma` of RVV
     // int PolicyAttrs = 0;
 
-    assert(PolicyAttrs.IsUnspecified == false);
-
     if (PolicyAttrs.isTUMAPolicy())
       return 2;
     if (PolicyAttrs.isTAMAPolicy())
index 25084dd..db78d83 100644 (file)
@@ -1017,7 +1017,6 @@ void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
   };
 
   if (PolicyAttrs.isUnspecified()) {
-    PolicyAttrs.IsUnspecified = false;
     if (IsMasked) {
       Name += "_m";
       if (HasPolicy)