[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 27 10:29:34 PST 2024
================
@@ -431,133 +434,130 @@ const std::array<SVEEmitter::ReinterpretTypeInfo, 12> SVEEmitter::Reinterprets =
// Type implementation
//===----------------------------------------------------------------------===//
-std::string SVEType::builtin_str() const {
- std::string OutStr;
-
- if (isScalarPredicate())
- return "b";
-
- if (isSvcount())
+std::string SVEType::builtinBaseType() const {
+ switch (Kind) {
+ case TypeKind::Void:
+ return "v";
+ case TypeKind::Svcount:
return "Qa";
-
- if (isVoid()) {
- OutStr += "v";
- if (!isPointer())
- return OutStr;
- } else if (isFloat()) {
+ case TypeKind::BFloat16:
+ assert(ElementBitwidth == 16 && "Invalid BFloat16!");
+ return "y";
+ case TypeKind::MFloat8:
+ assert(ElementBitwidth == 8 && "Invalid MFloat8!");
+ return "c";
+ case TypeKind::Float:
switch (ElementBitwidth) {
case 16:
- OutStr += "h";
- break;
+ return "h";
case 32:
- OutStr += "f";
- break;
+ return "f";
case 64:
- OutStr += "d";
- break;
+ return "d";
default:
- llvm_unreachable("Unhandled float type!");
+ llvm_unreachable("Unhandled float width!");
}
- } else if (isBFloat()) {
- assert(ElementBitwidth == 16 && "Not a valid BFloat.");
- OutStr += "y";
- } else if (isMFloat()) {
- assert(ElementBitwidth == 8 && "Not a valid MFloat.");
- OutStr += "m";
- } else {
+ case TypeKind::Predicate:
+ if (isScalar())
+ return "b";
+ [[fallthrough]];
+ // SInt/UInt, PredicatePattern, PrefetchOp.
+ default:
----------------
SpencerAbson wrote:
Good point, these should only be 32-bit - best handled in a similar way to `BFloat16`/`MFloat8` above?
https://github.com/llvm/llvm-project/pull/117717
More information about the cfe-commits
mailing list