[clang] [clang][Builtins] Parse clang extended vectors types. (PR #83584)

Francesco Petrogalli via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 11:15:14 PST 2024


================
@@ -85,6 +123,23 @@ class PrototypeParser {
       if (Substitution.empty())
         PrintFatalError(Loc, "Not a template");
       ParseType(Substitution);
+    } else if (T.consume_front("_ExtVector")) {
+      // Clang extended vector types are mangled as follows:
+      //
+      // '_ExtVector<' <lanes> ',' <scalar type> '>'
+      if (!T.consume_front("<"))
+        PrintFatalError(Loc, "Expected '<' after '_ExtVector'");
+      unsigned long long Lanes;
+      if (llvm::consumeUnsignedInteger(T, 10, Lanes))
+        PrintFatalError(Loc, "Expected number of lanes after '_ExtVector<'");
+      Type += "E" + std::to_string(Lanes);
+      if (!T.consume_front(","))
+        PrintFatalError(Loc,
+                        "Expected ',' after number of lanes in '_ExtVector<'");
+      if (!T.consume_back(">"))
+        PrintFatalError(
+            Loc, "Expected '>' after scalar type in '_ExtVector<N, type>'");
+      ParseType(T);
----------------
fpetrogalli wrote:

We need to do that because ParseType do not accept anything other than types. The whole string `_ExtVector<N,type>` is a type (maybe we can call it top-level type?)

Once we have verified that we have the whole `_ExtVector<N,type>`, we can narrow down and parse `type`.

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


More information about the cfe-commits mailing list