[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 22:48:00 PST 2024
================
@@ -317,38 +323,60 @@ ABIArgInfo RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
// Fixed-length RVV vectors are represented as scalable vectors in function
// args/return and must be coerced from fixed vectors.
-ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty) const {
+ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty,
+ unsigned ArgABIVLen) const {
assert(Ty->isVectorType() && "expected vector type!");
const auto *VT = Ty->castAs<VectorType>();
assert(VT->getElementType()->isBuiltinType() && "expected builtin type!");
- auto VScale =
- getContext().getTargetInfo().getVScaleRange(getContext().getLangOpts());
-
unsigned NumElts = VT->getNumElements();
- llvm::Type *EltType;
- if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask) {
- NumElts *= 8;
- EltType = llvm::Type::getInt1Ty(getVMContext());
+ llvm::ScalableVectorType *ResType;
+ llvm::Type *EltType = CGT.ConvertType(VT->getElementType());
+
+ if (ArgABIVLen == 0) {
+ // RVV fixed-length vector
+ auto VScale =
+ getContext().getTargetInfo().getVScaleRange(getContext().getLangOpts());
+
+ if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask) {
+ NumElts *= 8;
+ EltType = llvm::Type::getInt1Ty(getVMContext());
+ }
+
+ // The MinNumElts is simplified from equation:
+ // NumElts / VScale =
+ // (EltSize * NumElts / (VScale * RVVBitsPerBlock))
+ // * (RVVBitsPerBlock / EltSize)
+ ResType = llvm::ScalableVectorType::get(EltType, NumElts / VScale->first);
} else {
- assert(VT->getVectorKind() == VectorKind::RVVFixedLengthData &&
- "Unexpected vector kind");
- EltType = CGT.ConvertType(VT->getElementType());
+ // If the corresponding extension is not supported, just make it an i32
+ // vector.
+ const TargetInfo &TI = getContext().getTargetInfo();
----------------
topperc wrote:
Does this work with target_clones/target_version?
https://github.com/llvm/llvm-project/pull/100346
More information about the cfe-commits
mailing list