[llvm] [llvm] ABIInfo and TargetCodegenInfo (PR #190730)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 06:59:21 PDT 2026


================
@@ -0,0 +1,102 @@
+//===- ABIInfo.cpp - ABI information access & encapsulation
+//-----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ABI/ABIInfo.h"
+
+using namespace llvm::abi;
+
+bool ABIInfo::isAggregateTypeForABI(const Type *Ty) const {
+  // Check for fundamental scalar types
+  if (Ty->isInteger() || Ty->isFloat() || Ty->isPointer() || Ty->isVector())
+    return false;
+
+  // Everything else is treated as aggregate
+  return true;
+}
+
+bool ABIInfo::isPromotableInteger(const IntegerType *IT) const {
+  unsigned BitWidth = IT->getSizeInBits().getFixedValue();
+  return BitWidth < 32;
----------------
nikic wrote:

For reference:
https://github.com/llvm/llvm-project/blob/0e4f9ce0450cea43828a08bf4fcf8ca286a67c75/clang/lib/CodeGen/ABIInfo.cpp#L162
https://github.com/llvm/llvm-project/blob/0e4f9ce0450cea43828a08bf4fcf8ca286a67c75/clang/lib/AST/ASTContext.cpp#L1937

That doesn't quite match what's implemented here... But after poking around, I have some doubts about the current code as well, e.g. we emit `zeroext` for `char32_t`, even though it is the same size as int, so not actually subject to promotion.

I think I'd add a TODO here to make this use the actual integer size of the target (it's not always 32 bit).

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


More information about the llvm-commits mailing list