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

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 04:29:11 PST 2023


================
@@ -1477,6 +1479,34 @@ void VFABI::getVectorVariantNames(
   }
 }
 
+std::optional<std::pair<FunctionType *, int>>
+VFABI::createFunctionType(const VFInfo &Info, const FunctionType *ScalarFTy,
+                          Type *VecRetTy, const Module *M) {
+  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.
+  int MaskPos = -1;
+  if (Info.isMasked()) {
+    auto OptMaskPos = Info.getParamIndexForOptionalMask();
+    if (!OptMaskPos)
+      return std::nullopt;
+
+    MaskPos = OptMaskPos.value();
+    VectorType *MaskTy = VectorType::get(Type::getInt1Ty(M->getContext()), VF);
----------------
paulwalker-arm wrote:

You should be able to extract the context from `ScalarFTy` rather than need to pass in the module.

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


More information about the llvm-commits mailing list