aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
diff options
context:
space:
mode:
authorGang Chen <gangc@amd.com>2024-11-06 10:37:22 -0800
committerGitHub <noreply@github.com>2024-11-06 10:37:22 -0800
commit8c752900dda82115ebb8231e6d5ac703e703547e (patch)
treece774d8fa97a3ca4560d55c96b70969a280706dc /llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
parentffc2233395f0b1a3a0c277d196bb0a0ccae84ab7 (diff)
downloadllvm-8c752900dda82115ebb8231e6d5ac703e703547e.zip
llvm-8c752900dda82115ebb8231e6d5ac703e703547e.tar.gz
llvm-8c752900dda82115ebb8231e6d5ac703e703547e.tar.bz2
[AMDGPU] modify named barrier builtins and intrinsics (#114550)
Use a local pointer type to represent the named barrier in builtin and intrinsic. This makes the definitions more user friendly bacause they do not need to worry about the hardware ID assignment. Also this approach is more like the other popular GPU programming language. Named barriers should be represented as global variables of addrspace(3) in LLVM-IR. Compiler assigns the special LDS offsets for those variables during AMDGPULowerModuleLDS pass. Those addresses are converted to hw barrier ID during instruction selection. The rest of the instruction-selection changes are primarily due to the intrinsic-definition changes.
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
index 1d83d0c..f524764 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
@@ -8,6 +8,7 @@
#include "AMDGPUMachineFunction.h"
#include "AMDGPU.h"
+#include "AMDGPUMemoryUtils.h"
#include "AMDGPUPerfHintAnalysis.h"
#include "AMDGPUSubtarget.h"
#include "Utils/AMDGPUBaseInfo.h"
@@ -102,6 +103,13 @@ unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL,
unsigned Offset;
if (GV.getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
+ if (TargetExtType *TTy = AMDGPU::isNamedBarrier(GV)) {
+ std::optional<unsigned> BarAddr = getLDSAbsoluteAddress(GV);
+ if (!BarAddr)
+ llvm_unreachable("named barrier should have an assigned address");
+ Entry.first->second = BarAddr.value();
+ return BarAddr.value();
+ }
std::optional<uint32_t> MaybeAbs = getLDSAbsoluteAddress(GV);
if (MaybeAbs) {