13#ifndef LLVM_CGDATA_CODEGENDATAREADER_H
14#define LLVM_CGDATA_CODEGENDATAREADER_H
25 std::string LastErrorMsg;
52 create(std::unique_ptr<MemoryBuffer> Buffer);
68 LastErrorMsg = ErrMsg;
71 return make_error<CGDataError>(Err, ErrMsg);
76 LastError = IPE.
get();
79 return make_error<CGDataError>(LastError, LastErrorMsg);
88 std::unique_ptr<MemoryBuffer> DataBuffer;
94 : DataBuffer(
std::
move(DataBuffer)) {}
107 return static_cast<CGDataKind>(Header.DataKind);
112 return Header.DataKind &
124 std::unique_ptr<MemoryBuffer> DataBuffer;
132 : DataBuffer(
std::
move(DataBuffer_)), Line(*DataBuffer,
true,
'#') {}
147 return static_cast<uint32_t>(DataKind) &
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Defines the virtual file system interface vfs::FileSystem.
const std::string & getMessage() const
virtual bool hasOutlinedHashTree() const =0
Return true if the data has an outlined hash tree.
Error success()
Clear the current error and return a successful one.
virtual ~CodeGenDataReader()=default
virtual uint32_t getVersion() const =0
Return the codegen data version.
OutlinedHashTreeRecord HashTreeRecord
The outlined hash tree that has been read.
CodeGenDataReader()=default
static Expected< std::unique_ptr< CodeGenDataReader > > create(const Twine &Path, vfs::FileSystem &FS)
Factory method to create an appropriately typed reader for the given codegen data file path and file ...
Error error(cgdata_error Err, const std::string &ErrMsg="")
Set the current error and return same.
static Error mergeFromObjectFile(const object::ObjectFile *Obj, OutlinedHashTreeRecord &GlobalOutlineRecord)
Extract the cgdata embedded in sections from the given object file and merge them into the GlobalOutl...
virtual CGDataKind getDataKind() const =0
Return the codegen data kind.
virtual Error read()=0
Read the header. Required before reading first record.
std::unique_ptr< OutlinedHashTree > releaseOutlinedHashTree()
Return the outlined hash tree that is released from the reader.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if the given buffer is in binary codegen data format.
Error read() override
Read the contents including the header.
IndexedCodeGenDataReader(const IndexedCodeGenDataReader &)=delete
bool hasOutlinedHashTree() const override
Return true if the header indicates the data has an outlined hash tree.
IndexedCodeGenDataReader(std::unique_ptr< MemoryBuffer > DataBuffer)
CGDataKind getDataKind() const override
Return the codegen data kind.
IndexedCodeGenDataReader & operator=(const IndexedCodeGenDataReader &)=delete
uint32_t getVersion() const override
Return the codegen data version.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
This format is a simple text format that's suitable for test data.
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if the given buffer is in text codegen data format.
bool hasOutlinedHashTree() const override
Return true if the header indicates the data has an outlined hash tree.
Error read() override
Read the contents including the header.
TextCodeGenDataReader & operator=(const TextCodeGenDataReader &)=delete
uint32_t getVersion() const override
Text format does not have version, so return 0.
TextCodeGenDataReader(const TextCodeGenDataReader &)=delete
TextCodeGenDataReader(std::unique_ptr< MemoryBuffer > DataBuffer_)
CGDataKind getDataKind() const override
Return the codegen data kind.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A forward iterator which reads text lines from a buffer.
This class is the base class for all object file types.
The virtual file system interface.
This is an optimization pass for GlobalISel generic memory operations.
@ FunctionOutlinedHashTree
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
std::unique_ptr< OutlinedHashTree > HashTree