================
@@ -195,10 +230,114 @@ ArgInfo AArch64TargetInfo::classifyArgumentType(
 }
 
 bool AArch64TargetInfo::passAsAggregateType(const Type *Ty) const {
-  // TODO: Handle SVE types. For now, they don't get through the type mapper.
+  if (Opts.Kind == AArch64ABIKind::AAPCS && Ty->isSVESizelessType()) {
+    // svcount_t and the single-vector types occupy a register of their own,
+    // so only the data and predicate tuples are passed as aggregates.
+    const auto *TupleTy = dyn_cast<TupleType>(Ty);
+    assert((!TupleTy || TupleTy->getNumVectors() > 1) &&
+           "unexpected single vector tuple");
+    return TupleTy && !TupleTy->getVectorType()->isSVECount();
+  }
   return isAggregateTypeForABI(Ty);
 }
 
+/// Returns the scalable vector type that \p VT, a fixed-length SVE vector,
+/// is passed as. A scalable SVE vector holds 128 bits per granule, so the
+/// scalable element count is 128 divided by the element size, regardless of
+/// how many elements the fixed-length type has.
+const VectorType *AArch64TargetInfo::convertFixedToScalableVectorType(
+    const VectorType *VT) const {
+  // TODO: Verify that this correctly handles MFloat8 when we decide on a
+  // mapping for that type.
+
+  if (VT->isFixedLengthSVEPredicate())
+    return TB.getScalablePredicateVectorType();
+
+  assert(VT->isFixedLengthSVEData() && "expected a fixed-length SVE vector!");
+
+  const Type *EltTy = VT->getElementType();
+  uint64_t EltBits = EltTy->getSizeInBits().getFixedValue();
+  assert(EltBits >= 8 && EltBits <= 64 && isPowerOf2_64(EltBits) &&
+         "unexpected element type for SVE data vector!");
+
+  return TB.getVectorType(EltTy, ElementCount::getScalable(128 / EltBits),
+                          llvm::Align(16), VectorKind::SVEData);
+}
+
+ArgInfo AArch64TargetInfo::coerceIllegalVector(const Type *Ty, unsigned &NSRN,
+                                               unsigned &NPRN) const {
+  const auto *VT = cast<VectorType>(Ty);
----------------
madhur13490 wrote:

Nit: this takes a Type * and immediately casts it, and the caller in 
classifyReturnType already has a VectorType. Could `coerceIllegalVector` and 
`isIllegalVectorType` both take const VectorType *, with a single dyn_cast at 
the call site in classifyArgumentType?

https://github.com/llvm/llvm-project/pull/225201
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to