[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)
Sander de Smalen via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 27 09:34:40 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:
----------------
sdesmalen-arm wrote:
Can you expand these explicitly, rather than using `default`?
I'm also surprised that PredicatePattern or PrefetchOp take an argument based on the element bitwidth, because both just end up just being an enum value in the builtin. I suspect something else is missing.
https://github.com/llvm/llvm-project/pull/117717
More information about the cfe-commits
mailing list