Skip to content

Commit 6c560ef

Browse files
authored
[AMDGPU] Add .entry_point back into PAL metadata (llvm#125505)
1 parent cde3c68 commit 6c560ef

File tree

12 files changed

+46
-22
lines changed

12 files changed

+46
-22
lines changed

llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@
2727
using namespace llvm;
2828
using namespace llvm::AMDGPU;
2929

30+
// Return the PAL metadata hardware shader stage name.
31+
static const char *getStageName(CallingConv::ID CC) {
32+
switch (CC) {
33+
case CallingConv::AMDGPU_PS:
34+
return ".ps";
35+
case CallingConv::AMDGPU_VS:
36+
return ".vs";
37+
case CallingConv::AMDGPU_GS:
38+
return ".gs";
39+
case CallingConv::AMDGPU_ES:
40+
return ".es";
41+
case CallingConv::AMDGPU_HS:
42+
return ".hs";
43+
case CallingConv::AMDGPU_LS:
44+
return ".ls";
45+
case CallingConv::AMDGPU_Gfx:
46+
llvm_unreachable("Callable shader has no hardware stage");
47+
default:
48+
return ".cs";
49+
}
50+
}
51+
3052
// Read the PAL metadata from IR metadata, where it was put by the frontend.
3153
void AMDGPUPALMetadata::readFromIR(Module &M) {
3254
auto *NamedMD = M.getNamedMetadata("amdgpu.pal.metadata.msgpack");
@@ -232,8 +254,18 @@ void AMDGPUPALMetadata::setEntryPoint(unsigned CC, StringRef Name) {
232254
if (isLegacy())
233255
return;
234256
// Msgpack format.
257+
// Entry point is updated to .entry_point_symbol and is set to the function
258+
// name
235259
getHwStage(CC)[".entry_point_symbol"] =
236260
MsgPackDoc.getNode(Name, /*Copy=*/true);
261+
262+
// Set .entry_point which is defined
263+
// to be _amdgpu_<stage> and _amdgpu_cs for non-shader functions
264+
SmallString<16> EPName("_amdgpu_");
265+
raw_svector_ostream EPNameOS(EPName);
266+
EPNameOS << getStageName(CC) + 1;
267+
getHwStage(CC)[".entry_point"] =
268+
MsgPackDoc.getNode(EPNameOS.str(), /*Copy=*/true);
237269
}
238270

239271
// Set the number of used vgprs in the metadata. This is an optional
@@ -943,28 +975,6 @@ msgpack::MapDocNode AMDGPUPALMetadata::getGraphicsRegisters() {
943975
return GraphicsRegisters.getMap();
944976
}
945977

946-
// Return the PAL metadata hardware shader stage name.
947-
static const char *getStageName(CallingConv::ID CC) {
948-
switch (CC) {
949-
case CallingConv::AMDGPU_PS:
950-
return ".ps";
951-
case CallingConv::AMDGPU_VS:
952-
return ".vs";
953-
case CallingConv::AMDGPU_GS:
954-
return ".gs";
955-
case CallingConv::AMDGPU_ES:
956-
return ".es";
957-
case CallingConv::AMDGPU_HS:
958-
return ".hs";
959-
case CallingConv::AMDGPU_LS:
960-
return ".ls";
961-
case CallingConv::AMDGPU_Gfx:
962-
llvm_unreachable("Callable shader has no hardware stage");
963-
default:
964-
return ".cs";
965-
}
966-
}
967-
968978
msgpack::DocNode &AMDGPUPALMetadata::refHwStage() {
969979
auto &N =
970980
MsgPackDoc.getRoot()

llvm/test/CodeGen/AMDGPU/amdpal-cs.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
; GCN-NEXT: amdpal.pipelines:
99
; GCN-NEXT: - .hardware_stages:
1010
; GCN-NEXT: .cs:
11+
; GCN-NEXT: .entry_point: _amdgpu_cs
1112
; GCN-NEXT: .entry_point_symbol: cs_amdpal
1213
; GCN-NEXT: .scratch_memory_size: 0
1314
; GCN: .registers:

llvm/test/CodeGen/AMDGPU/amdpal-es.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
; GCN-NEXT: amdpal.pipelines:
88
; GCN-NEXT: - .hardware_stages:
99
; GCN-NEXT: .es:
10+
; GCN-NEXT: .entry_point: _amdgpu_es
1011
; GCN-NEXT: .entry_point_symbol: es_amdpal
1112
; GCN-NEXT: .scratch_memory_size: 0
1213
; GCN: .registers:

llvm/test/CodeGen/AMDGPU/amdpal-gs.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
; GCN-NEXT: amdpal.pipelines:
99
; GCN-NEXT: - .hardware_stages:
1010
; GCN-NEXT: .gs:
11+
; GCN-NEXT: .entry_point: _amdgpu_gs
1112
; GCN-NEXT: .entry_point_symbol: gs_amdpal
1213
; GCN-NEXT: .scratch_memory_size: 0
1314
; GCN: .registers:

llvm/test/CodeGen/AMDGPU/amdpal-hs.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
; GCN-NEXT: amdpal.pipelines:
99
; GCN-NEXT: - .hardware_stages:
1010
; GCN-NEXT: .hs:
11+
; GCN-NEXT: .entry_point: _amdgpu_hs
1112
; GCN-NEXT: .entry_point_symbol: hs_amdpal
1213
; GCN-NEXT: .scratch_memory_size: 0
1314
; GCN: .registers:

llvm/test/CodeGen/AMDGPU/amdpal-ls.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
; GCN-NEXT: amdpal.pipelines:
88
; GCN-NEXT: - .hardware_stages:
99
; GCN-NEXT: .ls:
10+
; GCN-NEXT: .entry_point: _amdgpu_ls
1011
; GCN-NEXT: .entry_point_symbol: ls_amdpal
1112
; GCN-NEXT: .scratch_memory_size: 0
1213
; GCN: .registers:

llvm/test/CodeGen/AMDGPU/amdpal-psenable.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
; GCN-NEXT: amdpal.pipelines:
1212
; GCN-NEXT: - .hardware_stages:
1313
; GCN-NEXT: .ps:
14+
; GCN-NEXT: .entry_point: _amdgpu_ps
1415
; GCN-NEXT: .entry_point_symbol: amdpal_psenable
1516
; GCN-NEXT: .scratch_memory_size: 0
1617
; GCN: .registers:

llvm/test/CodeGen/AMDGPU/amdpal-vs.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
; GCN-NEXT: amdpal.pipelines:
99
; GCN-NEXT: - .hardware_stages:
1010
; GCN-NEXT: .vs:
11+
; GCN-NEXT: .entry_point: _amdgpu_vs
1112
; GCN-NEXT: .entry_point_symbol: vs_amdpal
1213
; GCN-NEXT: .scratch_memory_size: 0
1314
; GCN: .registers:

llvm/test/CodeGen/AMDGPU/amdpal.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ declare void @llvm.amdgcn.raw.ptr.buffer.store.f32(float, ptr addrspace(8), i32,
8686
; PAL-NEXT: amdpal.pipelines:
8787
; PAL-NEXT: - .hardware_stages:
8888
; PAL-NEXT: .cs:
89+
; PAL-NEXT: .entry_point: _amdgpu_cs
8990
; PAL-NEXT: .entry_point_symbol: scratch2_cs
9091
; PAL-NEXT: .scratch_memory_size: 0x10
9192
; PAL-NEXT: .sgpr_count: 0x

llvm/test/CodeGen/AMDGPU/elf-notes.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
; OSABI-PAL-ELF: amdpal.pipelines:
6767
; OSABI-PAL-ELF: - .hardware_stages:
6868
; OSABI-PAL-ELF: .cs:
69+
; OSABI-PAL-ELF: .entry_point: _amdgpu_cs
6970
; OSABI-PAL-ELF: .entry_point_symbol: elf_notes
7071
; OSABI-PAL-ELF: .scratch_memory_size: 0
7172
; OSABI-PAL-ELF: .sgpr_count: 96

0 commit comments

Comments
 (0)