[flang-commits] [flang] [flang][PPC] Improve vector type names in expression diagnostics (NFC) (PR #199383)

Vir Patel via flang-commits flang-commits at lists.llvm.org
Tue May 26 13:49:38 PDT 2026


================
@@ -181,4 +182,39 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
   }
 }
 
-} // namespace Fortran::common
+std::string FormatVectorTypeAsFortran(
+    int category, int64_t elementCategory, int64_t elementKind) {
+  std::string buf;
+  llvm::raw_string_ostream ss{buf};
+
+  switch (category) {
+  case 1: { // IntrinsicVector
+    CHECK(elementCategory >= 0 && elementKind > 0);
+    ss << "vector(";
+    switch (static_cast<VectorElementCategory>(elementCategory)) {
+    case VectorElementCategory::Integer:
+      ss << "integer(" << elementKind << ")";
+      break;
+    case VectorElementCategory::Unsigned:
+      ss << "unsigned(" << elementKind << ")";
+      break;
+    case VectorElementCategory::Real:
+      ss << "real(" << elementKind << ")";
+      break;
+    }
+    ss << ")";
+    break;
+  }
+  case 2: // PairVector
+    ss << "__vector_pair";
+    break;
+  case 3: // QuadVector
+    ss << "__vector_quad";
+    break;
+  default:
+    CHECK(false && "Vector element type not implemented");
+  }
+  return buf;
+}
+
+} // namespace Fortran::common
----------------
virsworld wrote:

I tested it and looks like clang-format gets rid of newlines at end of file. At least it did for this file.

https://github.com/llvm/llvm-project/pull/199383


More information about the flang-commits mailing list