https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/95728
>From 2b500ad9ef2baf27da29146ddddb5a4123dcb75e Mon Sep 17 00:00:00 2001 From: Alex Voicu <alexandru.vo...@amd.com> Date: Mon, 17 Jun 2024 02:15:00 +0100 Subject: [PATCH 1/2] Add interface for exposing a target's flat address space, if it exists. --- clang/include/clang/Basic/TargetInfo.h | 7 +++++++ clang/lib/Basic/Targets/AMDGPU.h | 6 ++++++ clang/lib/Basic/Targets/SPIR.h | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8a6511b9ced83..8841ec5f910d9 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1764,6 +1764,13 @@ class TargetInfo : public TransferrableTargetInfo, return 0; } + /// \returns Target specific flat ptr address space; a flat ptr is a ptr that + /// can be casted to / from all other target address spaces. If the target + /// exposes no such address space / does not care, we return 0. + virtual unsigned getFlatPtrAddressSpace() const { + return 0; + } + /// \returns If a target requires an address within a target specific address /// space \p AddressSpace to be converted in order to be used, then return the /// corresponding target specific DWARF address space. diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index 94d9ba93ed226..d06c7d58fe94c 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -379,6 +379,12 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { return static_cast<unsigned>(llvm::AMDGPUAS::CONSTANT_ADDRESS); } + /// \returns Target specific flat ptr address space; a flat ptr is a ptr that + /// can be casted to / from all other target address spaces. + unsigned getFlatPtrAddressSpace() const override { + return static_cast<unsigned>(llvm::AMDGPUAS::FLAT_ADDRESS); + } + /// \returns If a target requires an address within a target specific address /// space \p AddressSpace to be converted in order to be used, then return the /// corresponding target specific DWARF address space. diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h index 37cf9d7921bac..14d235bace960 100644 --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -182,6 +182,10 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo { return TargetInfo::VoidPtrBuiltinVaList; } + unsigned getFlatPtrAddressSpace() const override { + return 4u; // 4 is generic i.e. flat for SPIR & SPIR-V. + } + std::optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace) const override { return AddressSpace; >From 346877d118700a748bffa8b0aee8633d6991582c Mon Sep 17 00:00:00 2001 From: Alex Voicu <alexandru.vo...@amd.com> Date: Mon, 17 Jun 2024 12:58:04 +0100 Subject: [PATCH 2/2] Fix formatting. --- clang/include/clang/Basic/TargetInfo.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8841ec5f910d9..a3b60db122cae 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1767,9 +1767,7 @@ class TargetInfo : public TransferrableTargetInfo, /// \returns Target specific flat ptr address space; a flat ptr is a ptr that /// can be casted to / from all other target address spaces. If the target /// exposes no such address space / does not care, we return 0. - virtual unsigned getFlatPtrAddressSpace() const { - return 0; - } + virtual unsigned getFlatPtrAddressSpace() const { return 0; } /// \returns If a target requires an address within a target specific address /// space \p AddressSpace to be converted in order to be used, then return the _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits