[llvm] [ABI][AMDGPU] Add AMDGPU target ABI classifier to the LLVM ABI library (PR #220177)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 00:26:50 PDT 2026
================
@@ -0,0 +1,300 @@
+//===- AMDGPU.cpp - AMDGPU ABI Implementation ----------------------------===//
+//
+// 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/FunctionInfo.h"
+#include "llvm/ABI/TargetInfo.h"
+#include "llvm/ABI/Types.h"
+#include "llvm/Support/AMDGPUAddrSpace.h"
+#include "llvm/Support/Alignment.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/TypeSize.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+
+namespace llvm {
+namespace abi {
+
+class AMDGPUTargetInfo : public TargetInfo {
+private:
+ static const unsigned MaxNumRegsForArgsRet = 16;
+
+ /// HIP coerces a generic scalar-pointer kernel argument to the global
+ /// address space. Gated by the front end, which alone can see LangOpts.HIP.
+ bool CoerceGenericPtrArgToGlobal;
+
+ ArgInfo classifyReturnType(const Type *RetTy) const;
+ ArgInfo classifyKernelArgumentType(const Type *Ty) const;
+ ArgInfo classifyArgumentType(const Type *Ty, bool Variadic,
+ unsigned &NumRegsLeft) const;
+
+ /// Target-independent fallback classification for arguments and returns.
+ ArgInfo classifyDefaultArgumentType(const Type *Ty) const;
+ ArgInfo classifyDefaultReturnType(const Type *Ty) const;
+
+ /// Estimate number of registers the type will use when passed in registers.
+ uint64_t numRegsForType(const Type *Ty) const;
+
+public:
+ AMDGPUTargetInfo(TypeBuilder &TypeBuilder, const ABICompatInfo &Compat,
+ bool CoerceGenericPtrArgToGlobal)
+ : TargetInfo(TypeBuilder, Compat),
+ CoerceGenericPtrArgToGlobal(CoerceGenericPtrArgToGlobal) {}
+
+ void computeInfo(FunctionInfo &FI) const override;
+};
+
+uint64_t AMDGPUTargetInfo::numRegsForType(const Type *Ty) const {
----------------
skc7 wrote:
Renamed `numRegsForType` to `getNumRegsForType` in latest patch.
https://github.com/llvm/llvm-project/pull/220177
More information about the llvm-commits
mailing list