[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 28 13:59:37 PST 2024


================
@@ -50,20 +50,30 @@ using TypeSpec = std::string;
 
 namespace {
 class SVEType {
-  bool Float, Signed, Immediate, Void, Constant, Pointer, BFloat, MFloat;
-  bool DefaultType, IsScalable, Predicate, PredicatePattern, PrefetchOp,
-      Svcount;
+
+  enum TypeKind {
+    Void,
+    Float,
+    SInt,
+    UInt,
+    BFloat16,
+    MFloat8,
+    Svcount,
+    PrefetchOp,
+    PredicatePattern,
+    Predicate
+  };
+  TypeKind Kind;
+  bool Immediate, Constant, Pointer, DefaultType, IsScalable;
   unsigned Bitwidth, ElementBitwidth, NumVectors;
 
 public:
   SVEType() : SVEType("", 'v') {}
 
   SVEType(StringRef TS, char CharMod, unsigned NumVectors = 1)
-      : Float(false), Signed(true), Immediate(false), Void(false),
-        Constant(false), Pointer(false), BFloat(false), MFloat(false),
-        DefaultType(false), IsScalable(true), Predicate(false),
-        PredicatePattern(false), PrefetchOp(false), Svcount(false),
-        Bitwidth(128), ElementBitwidth(~0U), NumVectors(NumVectors) {
+      : Kind(SInt), Immediate(false), Constant(false), Pointer(false),
----------------
sdesmalen-arm wrote:

On `Kind(SInt)`, is there any code that depends on this default? Or could we make an `Invalid` enum value (defined above `Void`) , so that we can make sure that all `SVEType` objects are correct initialised when we use it for generating tables?

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


More information about the cfe-commits mailing list