[clang] [RISCV][NFC] Make generated intrinsic records more human-readable (PR #133710)
Kito Cheng via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 31 06:03:47 PDT 2025
================
@@ -1196,36 +1196,93 @@ SmallVector<PrototypeDescriptor> parsePrototypes(StringRef Prototypes) {
return PrototypeDescriptors;
}
+#define STRINGIFY(NAME) \
+ case NAME: \
+ OS << #NAME; \
+ break;
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum PolicyScheme PS) {
+ switch (PS) {
+ STRINGIFY(SchemeNone)
+ STRINGIFY(HasPassthruOperand)
+ STRINGIFY(HasPolicyOperand)
+ }
+ return OS;
+}
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum RVVRequire Require) {
+ switch (Require) {
+ STRINGIFY(RVV_REQ_RV64)
+ STRINGIFY(RVV_REQ_Zvfhmin)
+ STRINGIFY(RVV_REQ_Xsfvcp)
+ STRINGIFY(RVV_REQ_Xsfvfnrclipxfqf)
+ STRINGIFY(RVV_REQ_Xsfvfwmaccqqq)
+ STRINGIFY(RVV_REQ_Xsfvqmaccdod)
+ STRINGIFY(RVV_REQ_Xsfvqmaccqoq)
+ STRINGIFY(RVV_REQ_Zvbb)
+ STRINGIFY(RVV_REQ_Zvbc)
+ STRINGIFY(RVV_REQ_Zvkb)
+ STRINGIFY(RVV_REQ_Zvkg)
+ STRINGIFY(RVV_REQ_Zvkned)
+ STRINGIFY(RVV_REQ_Zvknha)
+ STRINGIFY(RVV_REQ_Zvknhb)
+ STRINGIFY(RVV_REQ_Zvksed)
+ STRINGIFY(RVV_REQ_Zvksh)
+ STRINGIFY(RVV_REQ_Zvfbfwma)
+ STRINGIFY(RVV_REQ_Zvfbfmin)
+ STRINGIFY(RVV_REQ_Zvfh)
+ STRINGIFY(RVV_REQ_Experimental)
+ default:
+ break;
+ }
+ return OS;
+}
+
+#undef STRINGIFY
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
+ const RequiredExtensions &Exts) {
+ OS << "{";
+ const char *Sep = "";
+ for (unsigned I = 0; I < RVV_REQ_NUM; I++) {
+ if (Exts[I]) {
+ OS << Sep << static_cast<RVVRequire>(I);
+ Sep = ", ";
+ }
+ }
----------------
kito-cheng wrote:
There is a small utils class to do that:
```suggestion
ListSeparator LS;
for (unsigned I = 0; I < RVV_REQ_NUM; I++) {
if (Exts[I]) {
OS << LS << static_cast<RVVRequire>(I);
}
}
```
https://github.com/llvm/llvm-project/pull/133710
More information about the cfe-commits
mailing list