Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 32 additions & 22 deletions llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@
using namespace llvm;
using namespace llvm::AMDGPU;

// Return the PAL metadata hardware shader stage name.
static const char *getStageName(CallingConv::ID CC) {
switch (CC) {
case CallingConv::AMDGPU_PS:
return ".ps";
case CallingConv::AMDGPU_VS:
return ".vs";
case CallingConv::AMDGPU_GS:
return ".gs";
case CallingConv::AMDGPU_ES:
return ".es";
case CallingConv::AMDGPU_HS:
return ".hs";
case CallingConv::AMDGPU_LS:
return ".ls";
case CallingConv::AMDGPU_Gfx:
llvm_unreachable("Callable shader has no hardware stage");
default:
return ".cs";
}
}

// Read the PAL metadata from IR metadata, where it was put by the frontend.
void AMDGPUPALMetadata::readFromIR(Module &M) {
auto *NamedMD = M.getNamedMetadata("amdgpu.pal.metadata.msgpack");
Expand Down Expand Up @@ -232,8 +254,18 @@ void AMDGPUPALMetadata::setEntryPoint(unsigned CC, StringRef Name) {
if (isLegacy())
return;
// Msgpack format.
// Entry point is updated to .entry_point_symbol and is set to the function
// name
getHwStage(CC)[".entry_point_symbol"] =
MsgPackDoc.getNode(Name, /*Copy=*/true);

// Set .entry_point which is defined
// to be _amdgpu_<stage> and _amdgpu_cs for non-shader functions
SmallString<16> EPName("_amdgpu_");
raw_svector_ostream EPNameOS(EPName);
EPNameOS << getStageName(CC) + 1;
getHwStage(CC)[".entry_point"] =
MsgPackDoc.getNode(EPNameOS.str(), /*Copy=*/true);
}

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

// Return the PAL metadata hardware shader stage name.
static const char *getStageName(CallingConv::ID CC) {
switch (CC) {
case CallingConv::AMDGPU_PS:
return ".ps";
case CallingConv::AMDGPU_VS:
return ".vs";
case CallingConv::AMDGPU_GS:
return ".gs";
case CallingConv::AMDGPU_ES:
return ".es";
case CallingConv::AMDGPU_HS:
return ".hs";
case CallingConv::AMDGPU_LS:
return ".ls";
case CallingConv::AMDGPU_Gfx:
llvm_unreachable("Callable shader has no hardware stage");
default:
return ".cs";
}
}

msgpack::DocNode &AMDGPUPALMetadata::refHwStage() {
auto &N =
MsgPackDoc.getRoot()
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal-cs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .cs:
; GCN-NEXT: .entry_point: _amdgpu_cs
; GCN-NEXT: .entry_point_symbol: cs_amdpal
; GCN-NEXT: .scratch_memory_size: 0
; GCN: .registers:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal-es.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .es:
; GCN-NEXT: .entry_point: _amdgpu_es
; GCN-NEXT: .entry_point_symbol: es_amdpal
; GCN-NEXT: .scratch_memory_size: 0
; GCN: .registers:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal-gs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .gs:
; GCN-NEXT: .entry_point: _amdgpu_gs
; GCN-NEXT: .entry_point_symbol: gs_amdpal
; GCN-NEXT: .scratch_memory_size: 0
; GCN: .registers:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal-hs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .hs:
; GCN-NEXT: .entry_point: _amdgpu_hs
; GCN-NEXT: .entry_point_symbol: hs_amdpal
; GCN-NEXT: .scratch_memory_size: 0
; GCN: .registers:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal-ls.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .ls:
; GCN-NEXT: .entry_point: _amdgpu_ls
; GCN-NEXT: .entry_point_symbol: ls_amdpal
; GCN-NEXT: .scratch_memory_size: 0
; GCN: .registers:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal-psenable.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .ps:
; GCN-NEXT: .entry_point: _amdgpu_ps
; GCN-NEXT: .entry_point_symbol: amdpal_psenable
; GCN-NEXT: .scratch_memory_size: 0
; GCN: .registers:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal-vs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .vs:
; GCN-NEXT: .entry_point: _amdgpu_vs
; GCN-NEXT: .entry_point_symbol: vs_amdpal
; GCN-NEXT: .scratch_memory_size: 0
; GCN: .registers:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/amdpal.ll
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ declare void @llvm.amdgcn.raw.ptr.buffer.store.f32(float, ptr addrspace(8), i32,
; PAL-NEXT: amdpal.pipelines:
; PAL-NEXT: - .hardware_stages:
; PAL-NEXT: .cs:
; PAL-NEXT: .entry_point: _amdgpu_cs
; PAL-NEXT: .entry_point_symbol: scratch2_cs
; PAL-NEXT: .scratch_memory_size: 0x10
; PAL-NEXT: .sgpr_count: 0x
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/elf-notes.ll
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
; OSABI-PAL-ELF: amdpal.pipelines:
; OSABI-PAL-ELF: - .hardware_stages:
; OSABI-PAL-ELF: .cs:
; OSABI-PAL-ELF: .entry_point: _amdgpu_cs
; OSABI-PAL-ELF: .entry_point_symbol: elf_notes
; OSABI-PAL-ELF: .scratch_memory_size: 0
; OSABI-PAL-ELF: .sgpr_count: 96
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/AMDGPU/pal-metadata-3.0.ll
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
; CHECK-NEXT: .cs:
; CHECK-NEXT: .checksum_value: 0x9444d7d0
; CHECK-NEXT: .debug_mode: false
; CHECK-NEXT: .entry_point: _amdgpu_cs
; CHECK-NEXT: .entry_point_symbol: _amdgpu_cs_main
; CHECK-NEXT: .excp_en: 0
; CHECK-NEXT: .float_mode: 0xc0
Expand Down Expand Up @@ -109,6 +110,7 @@
; CHECK-NEXT: .wgp_mode: false
; CHECK-NEXT: .gs:
; CHECK-NEXT: .debug_mode: false
; CHECK-NEXT: .entry_point: _amdgpu_gs
; CHECK-NEXT: .entry_point_symbol: gs_shader
; CHECK-NEXT: .ieee_mode: false
; CHECK-NEXT: .lds_size: 0x200
Expand All @@ -120,6 +122,7 @@
; CHECK-NEXT: .wgp_mode: true
; CHECK-NEXT: .hs:
; CHECK-NEXT: .debug_mode: false
; CHECK-NEXT: .entry_point: _amdgpu_hs
; CHECK-NEXT: .entry_point_symbol: hs_shader
; CHECK-NEXT: .ieee_mode: false
; CHECK-NEXT: .lds_size: 0x1000
Expand All @@ -131,6 +134,7 @@
; CHECK-NEXT: .wgp_mode: true
; CHECK-NEXT: .ps:
; CHECK-NEXT: .debug_mode: false
; CHECK-NEXT: .entry_point: _amdgpu_ps
; CHECK-NEXT: .entry_point_symbol: ps_shader
; CHECK-NEXT: .ieee_mode: false
; CHECK-NEXT: .lds_size: 0
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/wave_dispatch_regs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
; GCN-NEXT: amdpal.pipelines:
; GCN-NEXT: - .hardware_stages:
; GCN-NEXT: .cs:
; GCN-NEXT: .entry_point: _amdgpu_cs
; GCN-NEXT: .entry_point_symbol: _amdgpu_cs_main
; GCN-NEXT: .scratch_memory_size: 0
; SI-NEXT: .sgpr_count: 0x11
Expand Down