summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
diff options
context:
space:
mode:
authorTim Renouf <tpr.llvm@botech.co.uk>2019-03-20 18:47:21 +0000
committerTim Renouf <tpr.llvm@botech.co.uk>2019-03-20 18:47:21 +0000
commite7bd52f86e040002fff8cc3e85cd0c9c24d801c0 (patch)
tree723faa3c98d2bfea7b74155a2cbf555accf879f7 /llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
parente4588bbf80ab24dc593ef8af88ed93010acbc90a (diff)
downloadbcm5719-llvm-e7bd52f86e040002fff8cc3e85cd0c9c24d801c0.tar.gz
bcm5719-llvm-e7bd52f86e040002fff8cc3e85cd0c9c24d801c0.zip
[AMDGPU] Added MsgPack format PAL metadata
Summary: PAL metadata now supports both the old linear reg=val pairs format and the new MsgPack format. The MsgPack format uses YAML as its textual representation. On output to YAML, a mnemonic name is provided for some hardware registers. Differential Revision: https://reviews.llvm.org/D57028 Change-Id: I2bbaabaaca4b3574f7e03b80fbef7c7a69d06a94 llvm-svn: 356591
Diffstat (limited to 'llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h')
-rw-r--r--llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h48
1 files changed, 46 insertions, 2 deletions
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
index 36a3ec457e3..e676c28da7b 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
@@ -15,6 +15,7 @@
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUPALMETADATA_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/MsgPackDocument.h"
#include <map>
namespace llvm {
@@ -25,7 +26,10 @@ class MCStreamer;
class Module;
class AMDGPUPALMetadata {
- std::map<uint32_t, uint32_t> Registers;
+ unsigned BlobType = 0;
+ msgpack::Document MsgPackDoc;
+ msgpack::DocNode Registers;
+ msgpack::DocNode HwStages;
public:
// Read the amdgpu.pal.metadata supplied by the frontend, ready for
@@ -60,6 +64,9 @@ public:
// In fact this ORs the value into any previous setting of the register.
void setRegister(unsigned Reg, unsigned Val);
+ // Set the entry point name for one shader.
+ void setEntryPoint(unsigned CC, StringRef Name);
+
// Set the number of used vgprs in the metadata. This is an optional advisory
// record for logging etc; wave dispatch actually uses the rsrc1 register for
// the shader stage to determine the number of vgprs to allocate.
@@ -73,13 +80,50 @@ public:
// Set the scratch size in the metadata.
void setScratchSize(unsigned CC, unsigned Val);
- // Emit the accumulated PAL metadata as an asm directive.
+ // Emit the accumulated PAL metadata as asm directives.
// This is called from AMDGPUTargetAsmStreamer::Finish().
void toString(std::string &S);
+ // Set PAL metadata from YAML text.
+ bool setFromString(StringRef S);
+
+ // Get .note record vendor name of metadata blob to be emitted.
+ const char *getVendor() const;
+
+ // Get .note record type of metadata blob to be emitted:
+ // ELF::NT_AMD_AMDGPU_PAL_METADATA (legacy key=val format), or
+ // ELF::NT_AMD_AMDGPU_PAL_METADATA_MSGPACK or ELF::NT_AMDGPU_METADATA
+ // (MsgPack format).
+ unsigned getType() const;
+
// Emit the accumulated PAL metadata as a binary blob.
// This is called from AMDGPUTargetELFStreamer::Finish().
void toBlob(unsigned Type, std::string &S);
+
+ // Get the msgpack::Document for the PAL metadata.
+ msgpack::Document *getMsgPackDoc() { return &MsgPackDoc; }
+
+ // Set legacy PAL metadata format.
+ void setLegacy();
+
+private:
+ // Return whether the blob type is legacy PAL metadata.
+ bool isLegacy() const;
+
+ // Reference (create if necessary) the node for the registers map.
+ msgpack::DocNode &refRegisters();
+
+ // Get (create if necessary) the registers map.
+ msgpack::MapDocNode getRegisters();
+
+ // Get (create if necessary) the .hardware_stages entry for the given calling
+ // convention.
+ msgpack::MapDocNode getHwStage(unsigned CC);
+
+ bool setFromLegacyBlob(StringRef Blob);
+ bool setFromMsgPackBlob(StringRef Blob);
+ void toLegacyBlob(std::string &Blob);
+ void toMsgPackBlob(std::string &Blob);
};
} // end namespace llvm
OpenPOWER on IntegriCloud