[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:20 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)) {
----------------
paulwalker-arm wrote:
This only works because we know any mask parameter will be last?
Given the following code `VecTypes.insert(VecTypes.begin() + OptMaskPos.value(), MaskTy);` allows the mask to be anywhere I think we'd be better served being more explicit. For example:
```
ScalarParamIndex = 0;
foreach (Info.Shape.Parameters) {
if (ParamKind == GlobalPredicate) {
VecTypes.push_back(mask_type)
continue;
}
OperandType = getParamType(ScalarParamIndex++)
if (ParamKind == vector) {
OperandType = vector_type(OperandType, VF)
VecTypes.push_back(OperandType)
}
```
Perhaps there's a nicer c++ way to write this but you get the gist?
https://github.com/llvm/llvm-project/pull/75058
More information about the llvm-commits
mailing list