[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

Yueh-Ting (eop) Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 26 07:02:37 PST 2023


eopXD updated this revision to Diff 492437.
eopXD added a comment.

Update code. The removal of `PolicyAttrs.IsUnspecified = false;` under

  void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
                                          std::string &Name,
                                          std::string &BuiltinName,
                                          std::string &OverloadedName,
                                          Policy &PolicyAttrs) {
  
  /* ... */
    if (PolicyAttrs.isUnspecified()) {
    }

is incorrect becasue the `==` operator of the `Policy` object still uses it.
So repeating builtin-s were created (becasue repeating ones are not recognized
as duplicates), causing `riscv_vector_builtin_cg.inc` to explode.

The updated patch now only adds `const` qualifier to `TailPolicy` and
`MaskPolicy`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141796/new/

https://reviews.llvm.org/D141796

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===================================================================
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,15 +92,22 @@
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
     Undisturbed,
     Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+  bool IsUnspecified = false;
+
+private:
+  // 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) {}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141796.492437.patch
Type: text/x-patch
Size: 990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230126/7a91f6e5/attachment.bin>


More information about the cfe-commits mailing list