[clang] [AArch64] Implement reinterpret builtins for SVE vector tuples (PR #69598)

Momchil Velikov via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 24 07:28:02 PDT 2023


================
@@ -263,17 +267,11 @@ class SVEEmitter {
   // which is inconvenient to specify in the arm_sve.td file or
   // generate in CGBuiltin.cpp.
   struct ReinterpretTypeInfo {
+    SVEType BaseType;
     const char *Suffix;
-    const char *Type;
-    const char *BuiltinType;
   };
-  SmallVector<ReinterpretTypeInfo, 12> Reinterprets = {
----------------
momchil-velikov wrote:

> Why you cannot do as you did before and only create an array for each size _x2, _x3 and _x4?
> 
> I believe you've changed the class SVEType, so you could use SVEType ToV(To.BaseType, N); and SVEType FromV(From.BaseType, N);. I am not sure we should do that.
> 
> But I am not sure if the changes are worth.

Certainly I can go and create three more similar arrays. What advantage would that have over the current solution?

With the current approach we have less repetition and the details of encoding of type names and type specifications are kept in one place and reused; that means there's less chance for a manual error when I type, e.g.  `"q2UWi"`; also the code
will automatically adjust to adding new types or changing the encoding.

(FWIW even `{SVEType("s"), "s16"},` is too much, would define `enum class Type { u8, s8, u16, s16, ... }` and have everything derived from these enumerators but there just should be a limit on the amount of refactoring in any single commit).


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


More information about the cfe-commits mailing list