[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 29 03:39:34 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),
----------------
SpencerAbson wrote:
I think this is a good idea, though it's a little tricky becuase the typespecs `'c'`, `'s'` ,`'i'` and`'l'` are often seen following a typespec modifier in arm_sve.td to change the element size (e.g, for predicates/SVCounts as you described before), and as typespecs in their own right (referring to the signed integer of their size, which is where the `Kind(SInt)` default comes from). One way to go about this is to make `'c'`, `'s'` ,`'i'` and`'l'` default to `SInt` if there is currently no type set, and leave the type unmodified if otherwise. Any thoughts?
https://github.com/llvm/llvm-project/pull/117717
More information about the cfe-commits
mailing list