[llvm] [SVE] Don't require lookup when demangling vector function mappings (PR #72260)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 10:39:26 PST 2023


================
@@ -273,49 +275,88 @@ ParseRet tryParseAlign(StringRef &ParseString, Align &Alignment) {
   return ParseRet::None;
 }
 
-#ifndef NDEBUG
-// Verify the assumtion that all vectors in the signature of a vector
-// function have the same number of elements.
-bool verifyAllVectorsHaveSameWidth(FunctionType *Signature) {
-  SmallVector<VectorType *, 2> VecTys;
-  if (auto *RetTy = dyn_cast<VectorType>(Signature->getReturnType()))
-    VecTys.push_back(RetTy);
-  for (auto *Ty : Signature->params())
-    if (auto *VTy = dyn_cast<VectorType>(Ty))
-      VecTys.push_back(VTy);
-
-  if (VecTys.size() <= 1)
-    return true;
-
-  assert(VecTys.size() > 1 && "Invalid number of elements.");
-  const ElementCount EC = VecTys[0]->getElementCount();
-  return llvm::all_of(llvm::drop_begin(VecTys), [&EC](VectorType *VTy) {
-    return (EC == VTy->getElementCount());
-  });
+// Given a type, return the size in bits if it is a supported element type
+// for vectorized function calls, or nullopt if not.
+std::optional<unsigned> getSizeFromScalarType(Type *Ty) {
----------------
paulwalker-arm wrote:

I'd like to propose a more hardwired approach.  What do you think about implementing `getVectorTypeFor(VABI_ARCH, Type)` or `getElementCountFor(VABI_ARCH, Type)` which today can just immediately assert VABI_ARCH is SVE, because the parsing will not get this far otherwise.

Then be very specific on the return.  For example:
```
if (isIntegerTy(64) || isDoubleTy() || isPointerTy())
  return ElementCount::getScalable(2);
if (isIntegerTy(32) || isFloatTy())
  return ElementCount::getScalable(4);
```
The usage below would then just need to pick the smallest one.

Ideally this would be the only function that contains target specific information.  In the future we might be able to funnel the clang side through the same mechanism.


https://github.com/llvm/llvm-project/pull/72260


More information about the llvm-commits mailing list