[llvm] [ABI] Add default argument/return classifiers to TargetInfo (PR #225009)

Steffen Larsen via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 04:25:23 PDT 2026


================
@@ -71,6 +71,45 @@ const Type *TargetInfo::useFirstFieldIfTransparentUnion(const Type *Ty) const {
   return Ty;
 }
 
+ArgInfo TargetInfo::classifyDefaultArgumentType(const Type *Ty) const {
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  if (isAggregateTypeForABI(Ty)) {
+    // A record that must stay in memory keeps ByVal, everything else indirect.
+    if (RecordArgABI RAA = getRecordArgABI(Ty))
+      return getNaturalAlignIndirect(Ty, /*ByVal=*/RAA == RAA_DirectInMemory);
+    return getNaturalAlignIndirect(Ty);
+  }
+
+  if (const auto *IT = dyn_cast<IntegerType>(Ty)) {
+    // A _BitInt wider than 128 bits does not fit in registers.
+    if (IT->isBitInt() && IT->getSizeInBits().getFixedValue() > 128)
+      return getNaturalAlignIndirect(Ty);
+    if (isPromotableInteger(IT))
+      return ArgInfo::getExtend(Ty);
+  }
+
+  return ArgInfo::getDirect();
+}
+
+ArgInfo TargetInfo::classifyDefaultReturnType(const Type *RetTy) const {
+  if (RetTy->isVoid())
+    return ArgInfo::getIgnore();
+
+  if (isAggregateTypeForABI(RetTy))
+    return getNaturalAlignIndirect(RetTy);
+
+  if (const auto *IT = dyn_cast<IntegerType>(RetTy)) {
+    // A _BitInt wider than 128 bits does not fit in registers.
+    if (IT->isBitInt() && IT->getSizeInBits().getFixedValue() > 128)
----------------
steffenlarsen wrote:

Same as https://github.com/llvm/llvm-project/pull/225009/changes#r4061635526

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


More information about the llvm-commits mailing list