[llvm] [VFABI] Create FunctionType for vector functions (PR #75058)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 05:53:21 PST 2023


================
@@ -1477,6 +1480,32 @@ void VFABI::getVectorVariantNames(
   }
 }
 
+FunctionType *VFABI::createFunctionType(const VFInfo &Info,
+                                        const FunctionType *ScalarFTy) {
+  ElementCount VF = Info.Shape.VF;
+  // Create vector parameter types
+  SmallVector<Type *, 8> VecTypes;
+  for (auto [STy, VFParam] : zip(ScalarFTy->params(), Info.Shape.Parameters)) {
+    if (VFParam.ParamKind == VFParamKind::Vector)
+      VecTypes.push_back(VectorType::get(STy, VF));
+    else
+      VecTypes.push_back(STy);
+  }
+
+  // Get mask's position mask and append one if not present in the Instruction.
+  if (auto OptMaskPos = Info.getParamIndexForOptionalMask()) {
+    if (!OptMaskPos)
+      return nullptr;
+    VectorType *MaskTy =
+        VectorType::get(Type::getInt1Ty(ScalarFTy->getContext()), VF);
+    VecTypes.insert(VecTypes.begin() + OptMaskPos.value(), MaskTy);
+  }
+  auto *RetTy = ScalarFTy->getReturnType();
+  if (!RetTy->isVoidTy())
+    RetTy = VectorType::get(ScalarFTy->getReturnType(), VF);
----------------
paulwalker-arm wrote:

Could reuse `RetTy` here instead of calling `getReturnType()` again.

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


More information about the llvm-commits mailing list