[llvm] Recommit [RISCV] RISCV vector calling convention (2/2) (#79096) (PR #87736)
Brandon Wu via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 19:33:55 PDT 2024
================
@@ -21102,6 +21091,206 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
return Subtarget.getMinimumJumpTableEntries();
}
+// Handle single arg such as return value.
+template <typename Arg>
+void RVVArgDispatcher::constructArgInfos(ArrayRef<Arg> ArgList) {
+ // This lambda determines whether an array of types are constructed by
+ // homogeneous vector types.
+ auto isHomogeneousScalableVectorType = [](ArrayRef<Arg> ArgList) {
+ // First, extract the first element in the argument type.
+ MVT FirstArgRegType;
+ unsigned FirstArgElements = 0;
+ auto It = ArgList.begin();
+ bool IsPart = false;
+
+ if (It == ArgList.end())
+ return false;
+
+ for (; It != ArgList.end(); ++It) {
+ FirstArgRegType = It->VT;
+ ++FirstArgElements;
+ if ((!It->Flags.isSplit() && !IsPart) || It->Flags.isSplitEnd())
+ break;
+
+ IsPart = true;
+ }
+
+ assert(It != ArgList.end() && "It shouldn't reach the end of ArgList.");
+ ++It;
+
+ // Return if this argument type contains only 1 element, or it's not a
+ // vector type.
+ if (It == ArgList.end() || !FirstArgRegType.isScalableVector())
+ return false;
+
+ // Second, check if the following elements in this argument type are all the
+ // same.
+ MVT ArgRegType;
+ unsigned ArgElements = 0;
+ IsPart = false;
+ for (; It != ArgList.end(); ++It) {
+ ArgRegType = It->VT;
+ ++ArgElements;
+ if ((!It->Flags.isSplit() && !IsPart) || It->Flags.isSplitEnd()) {
----------------
4vtomat wrote:
> Do we have tests for the split case? That should only happen for types larger than LMUL=8 I think? Do we even want to consider those as tuple types?
You are right and I think the split case doesn't need to be considered as tuple type since we only have 16 vregs, and the minimum split type is also LMUL=16, so it's impossible that argument that has more than 1 split type can be fully passed by reg.
I guess it can be handled as normal vector type.
https://github.com/llvm/llvm-project/pull/87736
More information about the llvm-commits
mailing list