[PATCH] D140263: [NFC] Vastly simplifies TypeSize

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 04:55:01 PST 2022


courbet added inline comments.


================
Comment at: llvm/include/llvm/Support/TypeSize.h:42
+/// to represent stack offsets.
+class StackOffset {
+  int64_t Fixed = 0;
----------------
Given that this is not a template over its unit, I think the doc should explicitly mention that the unit is bytes.


================
Comment at: llvm/include/llvm/Support/TypeSize.h:96
+//  |
+//  +-------- TypeSize - Leaf class to represent a type size
+//                       (vscale x uint64_t)
----------------
Update doc


================
Comment at: llvm/include/llvm/Support/TypeSize.h:100
 
-class StackOffset;
-template <> struct LinearPolyBaseTypeTraits<StackOffset> {
-  using ScalarTy = int64_t;
-  static constexpr unsigned Dimensions = 2;
-};
-
-/// StackOffset is a class to represent an offset with 2 dimensions,
-/// named fixed and scalable, respectively. This class allows a value for both
-/// dimensions to depict e.g. "8 bytes and 16 scalable bytes", which is needed
-/// to represent stack offsets.
-class StackOffset : public LinearPolyBase<StackOffset> {
-protected:
-  StackOffset(ScalarTy Fixed, ScalarTy Scalable)
-      : LinearPolyBase<StackOffset>({Fixed, Scalable}) {}
-
-public:
-  StackOffset() : StackOffset({0, 0}) {}
-  StackOffset(const LinearPolyBase<StackOffset> &Other)
-      : LinearPolyBase<StackOffset>(Other) {}
-  static StackOffset getFixed(ScalarTy Fixed) { return {Fixed, 0}; }
-  static StackOffset getScalable(ScalarTy Scalable) { return {0, Scalable}; }
-  static StackOffset get(ScalarTy Fixed, ScalarTy Scalable) {
-    return {Fixed, Scalable};
-  }
+template <typename LeafTy, typename ScalarT> class FixedOrScalableQuantity {
 
----------------
This is now abstractly named ("Quantity"), but the documentation  still refers to "size". 


================
Comment at: llvm/include/llvm/Support/TypeSize.h:163
+  bool isNonZero() const { return MinValue != 0; }
   explicit operator bool() const { return isNonZero(); }
 
----------------
Let's take this opportunity to document this non-obvious `bool` operator.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140263/new/

https://reviews.llvm.org/D140263



More information about the llvm-commits mailing list