[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 11 13:21:33 PST 2025


================
@@ -385,23 +580,50 @@ ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty) const {
     NumElts *= 8;
     break;
   default:
-    assert(VT->getVectorKind() == VectorKind::RVVFixedLengthData &&
+    assert((VT->getVectorKind() == VectorKind::Generic ||
+            VT->getVectorKind() == VectorKind::RVVFixedLengthData) &&
            "Unexpected vector kind");
     EltType = CGT.ConvertType(VT->getElementType());
   }
 
-  // The MinNumElts is simplified from equation:
-  // NumElts / VScale =
-  //  (EltSize * NumElts / (VScale * RVVBitsPerBlock))
-  //    * (RVVBitsPerBlock / EltSize)
-  llvm::ScalableVectorType *ResType =
-      llvm::ScalableVectorType::get(EltType, NumElts / VScale->first);
+  llvm::ScalableVectorType *ResType;
+
+  if (ABIVLen == 0) {
+    // The MinNumElts is simplified from equation:
+    // NumElts / VScale =
+    //  (EltSize * NumElts / (VScale * RVVBitsPerBlock))
+    //    * (RVVBitsPerBlock / EltSize)
+    ResType = llvm::ScalableVectorType::get(EltType, NumElts / VScale->first);
+  } else {
+    // If the corresponding extension is not supported, just make it an i32
+    // vector.
+    const TargetInfo &TI = getContext().getTargetInfo();
+    if ((EltType->isHalfTy() && !TI.hasFeature("zvfhmin")) ||
+        (EltType->isBFloatTy() && !TI.hasFeature("zvfbfmin")) ||
+        (EltType->isFloatTy() && !TI.hasFeature("zve32f")) ||
+        (EltType->isDoubleTy() && !TI.hasFeature("zve64d")) ||
+        EltType->isIntegerTy(128))
----------------
topperc wrote:

What about i64 with Zve32* but not V or Zve64*?

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


More information about the cfe-commits mailing list