|
27 | 27 | using namespace llvm; |
28 | 28 | using namespace llvm::AMDGPU; |
29 | 29 |
|
| 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 | + |
30 | 52 | // Read the PAL metadata from IR metadata, where it was put by the frontend. |
31 | 53 | void AMDGPUPALMetadata::readFromIR(Module &M) { |
32 | 54 | auto *NamedMD = M.getNamedMetadata("amdgpu.pal.metadata.msgpack"); |
@@ -232,8 +254,16 @@ void AMDGPUPALMetadata::setEntryPoint(unsigned CC, StringRef Name) { |
232 | 254 | if (isLegacy()) |
233 | 255 | return; |
234 | 256 | // Msgpack format. |
| 257 | + // Entry point is updated to .entry_point_symbol and is set to the function |
| 258 | + // name |
235 | 259 | getHwStage(CC)[".entry_point_symbol"] = |
236 | 260 | 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 | + std::string EPName("_amdgpu_"); |
| 265 | + EPName += std::string(getStageName(CC) + 1); |
| 266 | + getHwStage(CC)[".entry_point"] = MsgPackDoc.getNode(EPName, /*Copy=*/true); |
237 | 267 | } |
238 | 268 |
|
239 | 269 | // Set the number of used vgprs in the metadata. This is an optional |
@@ -943,28 +973,6 @@ msgpack::MapDocNode AMDGPUPALMetadata::getGraphicsRegisters() { |
943 | 973 | return GraphicsRegisters.getMap(); |
944 | 974 | } |
945 | 975 |
|
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 | | - |
968 | 976 | msgpack::DocNode &AMDGPUPALMetadata::refHwStage() { |
969 | 977 | auto &N = |
970 | 978 | MsgPackDoc.getRoot() |
|
0 commit comments