15#define DEBUG_TYPE "cg-data-writer"
20 using namespace support;
25 for (
const auto &K :
P) {
26 FDOStream.
seek(K.Pos);
27 for (
int I = 0;
I < K.N;
I++)
33 FDOStream.
seek(LastPos);
36 std::string &
Data = SOStream.
str();
37 for (
const auto &K :
P) {
38 for (
int I = 0;
I < K.N;
I++) {
40 endian::byte_swap<uint64_t, llvm::endianness::little>(K.D[
I]);
42 reinterpret_cast<const char *
>(&Bytes),
sizeof(
uint64_t));
49 assert(
Record.HashTree &&
"empty hash tree in the record");
56 assert(
Record.FunctionMap &&
"empty function map in the record");
64 return writeImpl(COS);
68 using namespace support;
81 Header.OutlinedHashTreeOffset = 0;
82 Header.StableFunctionMapOffset = 0;
86 COS.
write(Header.Magic);
91 OutlinedHashTreeOffset = COS.
tell();
97 StableFunctionMapOffset = COS.
tell();
106 if (
Error E = writeHeader(COS))
118 {OutlinedHashTreeOffset, &OutlinedHashTreeFieldStart, 1},
119 {StableFunctionMapOffset, &StableFunctionMapFieldStart, 1}};
120 COS.
patch(PatchItems);
127 OS <<
"# Outlined stable hash tree\n:outlined_hash_tree\n";
130 OS <<
"# Stable function map\n:stable_function_map\n";
138 if (
Error E = writeHeaderText(
OS))
141 yaml::Output YOS(
OS);
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A wrapper class to abstract writer stream with support of bytes back patching.
void patch(ArrayRef< CGDataPatchItem > P)
Error writeText(raw_fd_ostream &OS)
Write the codegen data in text format to OS.
Error write(raw_fd_ostream &OS)
Write the codegen data to OS.
bool hasOutlinedHashTree() const
Return true if the header indicates the data has an outlined hash tree.
bool hasStableFunctionMap() const
Return true if the header indicates the data has a stable function map.
void addRecord(OutlinedHashTreeRecord &Record)
Add the outlined hash tree record. The input hash tree is released.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
A raw_ostream that writes to a file descriptor.
uint64_t seek(uint64_t off)
Flushes the stream and repositions the underlying file descriptor position to the offset specified fr...
uint64_t tell() const
tell - Return the current offset with the file.
A raw_ostream that writes to an std::string.
std::string & str()
Returns the string's reference.
This is an optimization pass for GlobalISel generic memory operations.
@ StableFunctionMergingMap
@ FunctionOutlinedHashTree
A struct to define how the data stream should be patched.
void serializeYAML(yaml::Output &YOS) const
Serialize the outlined hash tree to a YAML stream.
void serialize(raw_ostream &OS) const
Serialize the outlined hash tree to a raw_ostream.
std::unique_ptr< OutlinedHashTree > HashTree
std::unique_ptr< StableFunctionMap > FunctionMap
static void serialize(raw_ostream &OS, const StableFunctionMap *FunctionMap)
A static helper function to serialize the stable function map without owning the stable function map.
void serializeYAML(yaml::Output &YOS) const
Serialize the stable function map to a YAML stream.