[PATCH] D139995: [RISCV] Refactor RVV Policy by structure

Kito Cheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 00:07:56 PST 2022


kito-cheng added inline comments.


================
Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:100
+  bool MU = false;
+  bool MA = false;
+  bool IntrinsicWithoutMU = false;
----------------
Maybe use enum value for tail/mask policy? *U and *A are mutually exclusive, so
 I feel they should just using same variables:  
```
  bool PolicyNone = false;
  enum PolicyType {
    Undisturbed,
    Agnostic,
    Omit, // No policy required.
  };

  PolicyType TailPolicy = Omit;
  PolicyType MastPolicy = Omit;
  bool IntrinsicWithoutMU = false;
```


================
Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:436
+
+    assert(false && "unsupport policy");
+    return 0;
----------------
llvm_unreachable


================
Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:167
   // We had initialized DefaultPolicy as TU/TUMU in CodeGen function.
-  if (RVVI->getDefaultPolicy() != Policy::TU &&
-      RVVI->getDefaultPolicy() != Policy::TUMU && !RVVI->hasPassthruOperand() &&
+  if (RVVI->getDefaultPolicyBits() != 0 && !RVVI->hasPassthruOperand() &&
       !RVVI->hasManualCodegen() && RVVI->hasVL())
----------------
Use `!RVVI->isTUPolicy() && !RVVI->isTUMUPolicy()` instead of `RVVI->getDefaultPolicyBits() != 0`, that's kind of too magical predication.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139995



More information about the cfe-commits mailing list