[AMDGPU] Factored PAL metadata handling out into its own class

Summary:
This commit introduces a new AMDGPUPALMetadata class that:
* is inside the AMDGPU target;
* keeps an in-memory representation of PAL metadata;
* provides a method to read the frontend-supplied metadata from LLVM IR;
* provides methods for the asm printer to set metadata items;
* provides methods to write the metadata as a binary blob to put in a
  .note record or as an asm directive;
* provides a method to read the metadata as a binary blob from a .note
  record.

Because llvm-readobj cannot call directly into a target, I had to remove
llvm-readobj's ability to dump PAL metadata, pending a resolution to
https://reviews.llvm.org/D52821

Differential Revision: https://reviews.llvm.org/D57027

Change-Id: I756dc830894fcb6850324cdcfa87c0120eb2cf64

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356582 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tim Renouf
2019-03-20 17:42:00 +00:00
parent b0941775f0
commit d1e92f3b2a
12 changed files with 360 additions and 161 deletions
-14
View File
@@ -218,19 +218,5 @@ std::error_code toString(Metadata HSAMetadata, std::string &String) {
}
} // end namespace HSAMD
namespace PALMD {
std::error_code toString(const Metadata &PALMetadata, std::string &String) {
raw_string_ostream Stream(String);
for (auto I = PALMetadata.begin(), E = PALMetadata.end(); I != E; ++I) {
Stream << Twine(I == PALMetadata.begin() ? " 0x" : ",0x");
Stream << Twine::utohexstr(*I);
}
Stream.flush();
return std::error_code();
}
} // end namespace PALMD
} // end namespace AMDGPU
} // end namespace llvm