[PATCH] D75297: [TypeSize] Allow returning scalable size in implicit conversion to uint64_t

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 13:04:48 PST 2020


sdesmalen created this revision.
sdesmalen added reviewers: efriedma, huntergr, rovka, ctetreau.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

This patch removes compiler runtime assertions that ensure the implicit
conversion are only guaranteed to work for fixed-width vectors.

With the assert it would be impossible to get _anything_ to build until the
entire codebase has been upgraded, even when the indiscriminate uses of
the size as uint64_t would work fine for both scalable and fixed-width
types.

This issue will need to be addressed differently, with build-time errors
rather than assertion failures, but that effort falls beyond the scope
of this patch.

Returning the scalable size and avoiding the assert in getFixedSize()
is a temporary stop-gap in order to use LLVM for compiling and using
the SVE ACLE intrinsics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75297

Files:
  llvm/include/llvm/Support/TypeSize.h


Index: llvm/include/llvm/Support/TypeSize.h
===================================================================
--- llvm/include/llvm/Support/TypeSize.h
+++ llvm/include/llvm/Support/TypeSize.h
@@ -145,11 +145,10 @@
   }
 
   // Casts to a uint64_t if this is a fixed-width size.
-  //
-  // NOTE: This interface is obsolete and will be removed in a future version
+  // FIXME: This interface is obsolete and will be removed in a future version
   // of LLVM in favour of calling getFixedSize() directly.
   operator uint64_t() const {
-    return getFixedSize();
+    return isScalable() ? getKnownMinSize() : getFixedSize();
   }
 
   // Additional convenience operators needed to avoid ambiguous parses.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75297.247078.patch
Type: text/x-patch
Size: 707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200227/7d954cac/attachment.bin>


More information about the llvm-commits mailing list