[PATCH] D78127: [SVE] Mark VectorType::getNumElements() deprecated

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 15:07:00 PDT 2020


ctetreau updated this revision to Diff 271495.
ctetreau added a comment.

deprecate rather than remove VectorType::getNumElements()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78127

Files:
  llvm/include/llvm/IR/DerivedTypes.h


Index: llvm/include/llvm/IR/DerivedTypes.h
===================================================================
--- llvm/include/llvm/IR/DerivedTypes.h
+++ llvm/include/llvm/IR/DerivedTypes.h
@@ -423,21 +423,11 @@
   /// Get the number of elements in this vector. It does not make sense to call
   /// this function on a scalable vector, and this will be moved into
   /// FixedVectorType in a future commit
-  unsigned getNumElements() const {
-    ElementCount EC = getElementCount();
-#ifdef STRICT_FIXED_SIZE_VECTORS
-    assert(!EC.Scalable &&
-           "Request for fixed number of elements from scalable vector");
-    return EC.Min;
-#else
-    if (EC.Scalable)
-      WithColor::warning()
-          << "The code that requested the fixed number of elements has made "
-             "the assumption that this vector is not scalable. This assumption "
-             "was not correct, and this may lead to broken code\n";
-    return EC.Min;
-#endif
-  }
+  LLVM_ATTRIBUTE_DEPRECATED(
+      inline unsigned getNumElements() const,
+      "Calling this function via a base VectorType is deprecated. Either call "
+      "getElementCount() and handle the case where Scalable is true or cast to "
+      "FixedVectorType.");
 
   Type *getElementType() const { return ContainedType; }
 
@@ -549,6 +539,22 @@
   }
 };
 
+unsigned VectorType::getNumElements() const {
+  ElementCount EC = getElementCount();
+#ifdef STRICT_FIXED_SIZE_VECTORS
+  assert(!EC.Scalable &&
+         "Request for fixed number of elements from scalable vector");
+  return EC.Min;
+#else
+  if (EC.Scalable)
+    WithColor::warning()
+        << "The code that requested the fixed number of elements has made the "
+           "assumption that this vector is not scalable. This assumption was "
+           "not correct, and this may lead to broken code\n";
+  return EC.Min;
+#endif
+}
+
 inline VectorType *VectorType::get(Type *ElementType, unsigned NumElements) {
   return VectorType::get(ElementType, NumElements, false);
 }
@@ -596,6 +602,8 @@
   static bool classof(const Type *T) {
     return T->getTypeID() == FixedVectorTyID;
   }
+
+  unsigned getNumElements() const { return ElementQuantity; }
 };
 
 /// Class to represent scalable SIMD vectors


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78127.271495.patch
Type: text/x-patch
Size: 2240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200617/d543f2a9/attachment.bin>


More information about the llvm-commits mailing list