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

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 27 06:36:45 PST 2024


================
@@ -424,72 +432,87 @@ 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";
 
   if (isSvcount())
     return "Qa";
 
-  if (isVoidPointer())
-    S += "v";
-  else if (!isFloatingPoint())
-    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())
+  if (isVoid()) {
+    OutStr += "v";
+    if (!isPointer())
+      return OutStr;
+  } 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";
-  }
-
-  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;
+    OutStr += "m";
+  } else {
----------------
SpencerAbson wrote:

Turns out we're sticking with `c` for the time being.

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


More information about the cfe-commits mailing list