Skip to content

[Clang][AArch64]Refactor typespec handling in SveEmitter.cpp #117717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 2, 2024

Conversation

SpencerAbson
Copy link
Contributor

@SpencerAbson SpencerAbson commented Nov 26, 2024

  • Switch to an enumerated type approach, which is less error-prone as we continue to add new types. This is similar to NeonEmitter.
  • Fix existing faulty typespec modifiers

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 26, 2024
@SpencerAbson SpencerAbson changed the title Refactor typespec handling in SveEmitter.cpp [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp Nov 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2024

@llvm/pr-subscribers-clang

Author: None (SpencerAbson)

Changes
  • Switch to a less error-prone enumerated type approach, similar to NeonEmitter.
  • Fix existing faulty typespec modifiers

Patch is 23.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/117717.diff

2 Files Affected:

  • (modified) clang/include/clang/Basic/arm_sve.td (+14-14)
  • (modified) clang/utils/TableGen/SveEmitter.cpp (+153-203)
diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td
index d492fae4145b92..3e4eb55213c39e 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -762,14 +762,14 @@ def SVCMPLS_WIDE_N : SInst<"svcmple_wide[_n_{d}]", "PPdj", "UcUsUi", MergeNone,
 ////////////////////////////////////////////////////////////////////////////////
 // While comparisons
 
-def SVWHILELE_S32 : SInst<"svwhilele_{d}[_{1}]", "Pkk", "PcPsPiPl",     MergeNone, "aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILELE_S64 : SInst<"svwhilele_{d}[_{1}]", "Pll", "PcPsPiPl",     MergeNone, "aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILELO_U32 : SInst<"svwhilelt_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILELO_U64 : SInst<"svwhilelt_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILELS_U32 : SInst<"svwhilele_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILELS_U64 : SInst<"svwhilele_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILELT_S32 : SInst<"svwhilelt_{d}[_{1}]", "Pkk", "PcPsPiPl",     MergeNone, "aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILELT_S64 : SInst<"svwhilelt_{d}[_{1}]", "Pll", "PcPsPiPl",     MergeNone, "aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELE_S32 : SInst<"svwhilele_{d}[_{1}]", "Pkk", "PcPsPiPl", MergeNone, "aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELE_S64 : SInst<"svwhilele_{d}[_{1}]", "Pll", "PcPsPiPl", MergeNone, "aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELO_U32 : SInst<"svwhilelt_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, "aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELO_U64 : SInst<"svwhilelt_{d}[_{1}]", "Pnn", "PcPsPiPl", MergeNone, "aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELS_U32 : SInst<"svwhilele_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, "aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELS_U64 : SInst<"svwhilele_{d}[_{1}]", "Pnn", "PcPsPiPl", MergeNone, "aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELT_S32 : SInst<"svwhilelt_{d}[_{1}]", "Pkk", "PcPsPiPl", MergeNone, "aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELT_S64 : SInst<"svwhilelt_{d}[_{1}]", "Pll", "PcPsPiPl", MergeNone, "aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Counting bit
@@ -1365,10 +1365,10 @@ def SVWHILEGE_S32 : SInst<"svwhilege_{d}[_{1}]", "Pkk", "PcPsPiPl",     MergeNon
 def SVWHILEGE_S64 : SInst<"svwhilege_{d}[_{1}]", "Pll", "PcPsPiPl",     MergeNone, "aarch64_sve_whilege", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
 def SVWHILEGT_S32 : SInst<"svwhilegt_{d}[_{1}]", "Pkk", "PcPsPiPl",     MergeNone, "aarch64_sve_whilegt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
 def SVWHILEGT_S64 : SInst<"svwhilegt_{d}[_{1}]", "Pll", "PcPsPiPl",     MergeNone, "aarch64_sve_whilegt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILEHI_U32 : SInst<"svwhilegt_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilehi", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILEHI_U64 : SInst<"svwhilegt_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilehi", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILEHS_U32 : SInst<"svwhilege_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilehs", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
-def SVWHILEHS_U64 : SInst<"svwhilege_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", MergeNone, "aarch64_sve_whilehs", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILEHI_U32 : SInst<"svwhilegt_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, "aarch64_sve_whilehi", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILEHI_U64 : SInst<"svwhilegt_{d}[_{1}]", "Pnn", "PcPsPiPl", MergeNone, "aarch64_sve_whilehi", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILEHS_U32 : SInst<"svwhilege_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, "aarch64_sve_whilehs", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILEHS_U64 : SInst<"svwhilege_{d}[_{1}]", "Pnn", "PcPsPiPl", MergeNone, "aarch64_sve_whilehs", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
 }
 
 let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2"  in {
@@ -2326,7 +2326,7 @@ let SVETargetGuard = "sve2p1,bf16", SMETargetGuard = "sme2p1,bf16" in {
 // Multi-vector convert to/from floating-point.
 //
 let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2" in {
-  def SVCVT_F16_X2  : SInst<"svcvt_f16[_f32_x2]", "e2", "f", MergeNone, "aarch64_sve_fcvt_x2", [IsStreaming],[]>;
+  def SVCVT_F16_X2  : SInst<"svcvt_f16[_f32_x2]", "h2", "f", MergeNone, "aarch64_sve_fcvt_x2", [IsStreaming],[]>;
   def SVCVT_BF16_X2 : SInst<"svcvt_bf16[_f32_x2]", "$2", "f", MergeNone, "aarch64_sve_bfcvt_x2", [IsOverloadNone, IsStreaming],[]>;
 
   def SVCVT_F32_U32_X2 : SInst<"svcvt_{d}[_u32_x2]", "2.d2.u", "f",  MergeNone, "aarch64_sve_ucvtf_x2",  [IsStreaming, IsOverloadWhileOrMultiVecCvt], []>;
@@ -2348,7 +2348,7 @@ let SVETargetGuard = InvalidMode, SMETargetGuard = "sme-f16f16" in {
 // Multi-vector floating-point convert from single-precision to interleaved half-precision/BFloat16
 //
 let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2" in {
-  def SVCVTN_F16_X2  : SInst<"svcvtn_f16[_f32_x2]", "e2", "f", MergeNone, "aarch64_sve_fcvtn_x2", [IsStreaming],[]>;
+  def SVCVTN_F16_X2  : SInst<"svcvtn_f16[_f32_x2]", "h2", "f", MergeNone, "aarch64_sve_fcvtn_x2", [IsStreaming],[]>;
   def SVCVTN_BF16_X2 : SInst<"svcvtn_bf16[_f32_x2]", "$2", "f", MergeNone, "aarch64_sve_bfcvtn_x2", [IsOverloadNone, IsStreaming],[]>;
 }
 
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index e8883488f32356..7419658f06bc15 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -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),
+        DefaultType(false), IsScalable(true), Bitwidth(128),
+        ElementBitwidth(~0U), NumVectors(NumVectors) {
     if (!TS.empty())
       applyTypespec(TS);
     applyModifier(CharMod);
@@ -74,33 +84,31 @@ class SVEType {
   }
 
   bool isPointer() const { return Pointer; }
-  bool isVoidPointer() const { return Pointer && Void; }
-  bool isSigned() const { return Signed; }
+  bool isConstant() const { return Constant; }
   bool isImmediate() const { return Immediate; }
+  bool isSigned() const { return Kind != UInt; }
   bool isScalar() const { return NumVectors == 0; }
   bool isVector() const { return NumVectors > 0; }
   bool isScalableVector() const { return isVector() && IsScalable; }
   bool isFixedLengthVector() const { return isVector() && !IsScalable; }
-  bool isChar() const { return ElementBitwidth == 8 && !MFloat; }
-  bool isVoid() const { return Void && !Pointer; }
+  bool isChar() const { return ElementBitwidth == 8 && isInteger(); }
+  bool isVoid() const { return Kind == Void; }
   bool isDefault() const { return DefaultType; }
-  bool isFloat() const { return Float && !BFloat && !MFloat; }
-  bool isBFloat() const { return BFloat && !Float && !MFloat; }
-  bool isMFloat() const {
-    return MFloat && !BFloat && !Float;
-  }
-  bool isFloatingPoint() const { return Float || BFloat; }
-  bool isInteger() const {
-    return !isFloatingPoint() && !Predicate && !Svcount;
+  bool isFloat() const { return Kind == Float; }
+  bool isBFloat() const { return Kind == BFloat16; }
+  bool isMFloat() const { return Kind == MFloat8; }
+  bool isTypedPointer() const { return Pointer && Kind != Void; }
+  bool isFloatingPoint() const {
+    return Kind == Float || Kind == BFloat16 || Kind == MFloat8;
   }
+  bool isInteger() const { return Kind == SInt || Kind == UInt; }
   bool isScalarPredicate() const {
-    return !isFloatingPoint() && Predicate && NumVectors == 0;
+    return Kind == Predicate && NumVectors == 0;
   }
-  bool isPredicateVector() const { return Predicate; }
-  bool isPredicatePattern() const { return PredicatePattern; }
-  bool isPrefetchOp() const { return PrefetchOp; }
-  bool isSvcount() const { return Svcount; }
-  bool isConstant() const { return Constant; }
+  bool isPredicate() const { return Kind == Predicate; }
+  bool isPredicatePattern() const { return Kind == PredicatePattern; }
+  bool isPrefetchOp() const { return Kind == PrefetchOp; }
+  bool isSvcount() const { return Kind == Svcount; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
   unsigned getNumVectors() const { return NumVectors; }
 
@@ -424,9 +432,7 @@ const std::array<SVEEmitter::ReinterpretTypeInfo, 12> SVEEmitter::Reinterprets =
 //===----------------------------------------------------------------------===//
 
 std::string SVEType::builtin_str() const {
-  std::string S;
-  if (isVoid())
-    return "v";
+  std::string OutStr;
 
   if (isScalarPredicate())
     return "b";
@@ -434,62 +440,81 @@ std::string SVEType::builtin_str() const {
   if (isSvcount())
     return "Qa";
 
-  if (isVoidPointer())
-    S += "v";
-  else if (!isFloatingPoint())
+  if (isVoid()) {
+    OutStr += "v";
+    if (!isPointer())
+      return OutStr;
+  } else if (isFloat()) {
     switch (ElementBitwidth) {
-    case 1: S += "b"; break;
-    case 8: S += "c"; break;
-    case 16: S += "s"; break;
-    case 32: S += "i"; break;
-    case 64: S += "Wi"; break;
-    case 128: S += "LLLi"; break;
-    default: llvm_unreachable("Unhandled case!");
-    }
-  else if (isFloat())
-    switch (ElementBitwidth) {
-    case 16: S += "h"; break;
-    case 32: S += "f"; break;
-    case 64: S += "d"; break;
-    default: llvm_unreachable("Unhandled case!");
+    case 16:
+      OutStr += "h";
+      break;
+    case 32:
+      OutStr += "f";
+      break;
+    case 64:
+      OutStr += "d";
+      break;
+    default:
+      llvm_unreachable("Unhandled float type!");
     }
-  else if (isBFloat()) {
+  } else if (isBFloat()) {
     assert(ElementBitwidth == 16 && "Not a valid BFloat.");
-    S += "y";
+    OutStr += "y";
   } else if (isMFloat()) {
     assert(ElementBitwidth == 8 && "Not a valid MFloat.");
-    S += "m";
+    OutStr += "m";
+  } else {
+    switch (ElementBitwidth) {
+    case 1:
+      OutStr += "b";
+      break;
+    case 8:
+      OutStr += "c";
+      break;
+    case 16:
+      OutStr += "s";
+      break;
+    case 32:
+      OutStr += "i";
+      break;
+    case 64:
+      OutStr += "Wi";
+      break;
+    case 128:
+      OutStr += "LLLi";
+      break;
+    default:
+      llvm_unreachable("Unhandled bitwidth!");
+    }
   }
 
-  if (!isFloatingPoint()) {
-    if ((isChar() || isPointer()) && !isVoidPointer()) {
-      // Make chars and typed pointers explicitly signed.
-      if (Signed)
-        S = "S" + S;
-      else if (!Signed)
-        S = "U" + S;
-    } else if (!isVoidPointer() && !Signed) {
-      S = "U" + S;
-    }
+  // Make chars and typed pointers explicitly signed.
+  if (!isFloatingPoint() && !isVoid()) {
+    if ((ElementBitwidth == 8 || isPointer()) && isSigned())
+      OutStr = "S" + OutStr;
+    if (!isSigned())
+      OutStr = "U" + OutStr;
   }
 
   // Constant indices are "int", but have the "constant expression" modifier.
   if (isImmediate()) {
-    assert(!isFloat() && "fp immediates are not supported");
-    S = "I" + S;
+    assert(!isFloatingPoint() && "fp immediates are not supported");
+    OutStr = "I" + OutStr;
   }
 
   if (isScalar()) {
-    if (Constant) S += "C";
-    if (Pointer) S += "*";
-    return S;
+    if (Constant)
+      OutStr += "C";
+    if (Pointer)
+      OutStr += "*";
+    return OutStr;
   }
 
   if (isFixedLengthVector())
-    return "V" + utostr(getNumElements() * NumVectors) + S;
-  return "q" + utostr(getNumElements() * NumVectors) + S;
+    return "V" + utostr(getNumElements() * NumVectors) + OutStr;
+  return "q" + utostr(getNumElements() * NumVectors) + OutStr;
 }
-
 std::string SVEType::str() const {
   if (isPredicatePattern())
     return "enum svpattern";
@@ -498,28 +523,30 @@ std::string SVEType::str() const {
     return "enum svprfop";
 
   std::string S;
-  if (Void)
+  if (isVoid())
     S += "void";
   else {
     if (isScalableVector() || isSvcount())
       S += "sv";
-    if (!Signed && !isFloatingPoint())
-      S += "u";
 
-    if (Float)
+    if (isFloat())
       S += "float";
     else if (isSvcount())
       S += "count";
-    else if (isScalarPredicate() || isPredicateVector())
+    else if (isPredicate())
       S += "bool";
     else if (isBFloat())
       S += "bfloat";
     else if (isMFloat())
       S += "mfloat";
-    else
-      S += "int";
+    else {
+      if (isSigned())
+        S += "int";
+      else
+        S += "uint";
+    };
 
-    if (!isScalarPredicate() && !isPredicateVector() && !isSvcount())
+    if (!isPredicate() && !isSvcount())
       S += utostr(ElementBitwidth);
     if (isFixedLengthVector())
       S += "x" + utostr(getNumElements());
@@ -541,13 +568,13 @@ void SVEType::applyTypespec(StringRef TS) {
   for (char I : TS) {
     switch (I) {
     case 'Q':
-      Svcount = true;
+      Kind = Svcount;
       break;
     case 'P':
-      Predicate = true;
+      Kind = Predicate;
       break;
     case 'U':
-      Signed = false;
+      Kind = UInt;
       break;
     case 'c':
       ElementBitwidth = 8;
@@ -565,28 +592,23 @@ void SVEType::applyTypespec(StringRef TS) {
       ElementBitwidth = 128;
       break;
     case 'h':
-      Float = true;
+      Kind = Float;
       ElementBitwidth = 16;
       break;
     case 'f':
-      Float = true;
+      Kind = Float;
       ElementBitwidth = 32;
       break;
     case 'd':
-      Float = true;
+      Kind = Float;
       ElementBitwidth = 64;
       break;
     case 'b':
-      BFloat = true;
-      Float = false;
-      MFloat = false;
+      Kind = BFloat16;
       ElementBitwidth = 16;
       break;
     case 'm':
-      Signed = false;
-      MFloat = true;
-      Float = false;
-      BFloat = false;
+      Kind = MFloat8;
       ElementBitwidth = 8;
       break;
     default:
@@ -599,7 +621,7 @@ void SVEType::applyTypespec(StringRef TS) {
 void SVEType::applyModifier(char Mod) {
   switch (Mod) {
   case 'v':
-    Void = true;
+    Kind = Void;
     break;
   case 'd':
     DefaultType = true;
@@ -613,7 +635,7 @@ void SVEType::applyModifier(char Mod) {
     NumVectors = 0;
     break;
   case 'e':
-    Signed = false;
+    Kind = UInt;
     ElementBitwidth /= 2;
     break;
   case 'h':
@@ -623,20 +645,14 @@ void SVEType::applyModifier(char Mod) {
     ElementBitwidth /= 4;
     break;
   case 'b':
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth /= 4;
     break;
   case 'o':
     ElementBitwidth *= 4;
     break;
   case 'P':
-    Signed = true;
-    Float = false;
-    BFloat = false;
-    Predicate = true;
-    Svcount = false;
+    Kind = Predicate;
     Bitwidth = 16;
     ElementBitwidth = 1;
     break;
@@ -659,105 +675,61 @@ void SVEType::applyModifier(char Mod) {
     NumVectors = 0;
     break;
   case '@':
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth /= 4;
     NumVectors = 0;
     break;
   case 'K':
-    Signed = true;
-    Float = false;
-    BFloat = false;
+    Kind = SInt;
     Bitwidth = ElementBitwidth;
     NumVectors = 0;
     break;
   case 'L':
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     Bitwidth = ElementBitwidth;
     NumVectors = 0;
     break;
   case 'u':
-    Predicate = false;
-    Svcount = false;
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     break;
   case 'x':
-    Predicate = false;
-    Svcount = false;
-    Signed = true;
-    Float = false;
-    BFloat = false;
+    Kind = SInt;
     break;
   case 'i':
-    Predicate = false;
-    Svcount = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth = Bitwidth = 64;
     NumVectors = 0;
-    Signed = false;
     Immediate = true;
     break;
   case 'I':
-    Predicate = false;
-    Svcount = false;
-    Float = false;
-    BFloat = false;
+    Kind = PredicatePattern;
     ElementBitwidth = Bitwidth = 32;
     NumVectors = 0;
-    Signed = true;
     Immediate = true;
-    PredicatePattern = true;
     break;
   case 'J':
-    Predicate = false;
-    Svcount = false;
-    Float = false;
-    BFloat = false;
+    Kind = PrefetchOp;
     ElementBitwidth = Bitwidth = 32;
     NumVectors = 0;
-    Signed = true;
     Immediate = true;
-    PrefetchOp = true;
     break;
   case 'k':
-    Predicate = false;
-    Svcount = false;
-    Signed = true;
-    Float = false;
-    BFloat = false;
+    Kind = SInt;
     ElementBitwidth = Bitwidth = 32;
     NumVectors = 0;
     break;
   case 'l':
-    Predicate = false;
-    Svcount = false;
-    Signed = true;
-    Float = false;
-    BFloat = false;
+    Kind = SInt;
     ElementBitwidth = Bitwidth = 64;
     NumVectors = 0;
     break;
   case 'm':
-    Predicate = false;
-    Svcount = false;
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth = Bitwidth = 32;
     NumVectors = 0;
     break;
   case 'n':
-    Predicate = false;
-    Svcount = false;
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth = Bitwidth = 64;
     NumVectors = 0;
     break;
@@ -769,162 +741,140 @@ void SVEType::applyModifier(char Mod) {
     NumVectors = 0;
     break;
   case 'f':
-    Signed = false;
+    Kind = UInt;
     ElementBitwidth = Bitwidth = 64;
     NumVectors = 0;
     break;
   case 'g':
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth = 64;
     break;
   case '[':
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth = 8;
     break;
   case 't':
-    Signed = true;
-    Float = false;
-    BFloat = false;
+    Kind = SInt;
     ElementBitwidth = 32;
     break;
   case 'z':
-    Signed = false;
-    Float = false;
-    BFloat = false;
+    Kind = UInt;
     ElementBitwidth = 32;
     break;
   case 'O':
-    Predicate = false;
-    Svcount = false;
-    Float = true;
+    Kind = Float;
     ElementBitwidth = 16;
     break;
   case 'M':
-    Predicate = false;
-    Svcount = false;
-    Float = true;
-    BFloat = false;
+    Kind = Float;
     ElementBitwidth = 32;
     break;
   case 'N':
-    Predicate = false;
-    Svcount = false;
-    Float = true;
+    Kind = Float;
     ElementBitwidth = 64;
     break;
   case 'Q':
+    Kind = Void;
     Constant = true;
     Pointer = true;
-    Void = true;
     NumVectors = 0;
     break;
   case 'S':
+    Kind = SInt;
     Constant = true;
     Pointe...
[truncated]

Copy link
Collaborator

@sdesmalen-arm sdesmalen-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up, this part was always quite messy!

Copy link
Collaborator

@sdesmalen-arm sdesmalen-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, but otherwise looks good!

Copy link
Collaborator

@sdesmalen-arm sdesmalen-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@SpencerAbson SpencerAbson merged commit ac7fe42 into llvm:main Dec 2, 2024
8 checks passed
@SpencerAbson
Copy link
Contributor Author

Thank you @sdesmalen-arm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants