17#ifndef LLVM_BINARYFORMAT_MSGPACKDOCUMENT_H
18#define LLVM_BINARYFORMAT_MSGPACKDOCUMENT_H
42 typedef std::map<DocNode, DocNode>
MapTy;
160 if (Lhs.KindAndDoc != Rhs.KindAndDoc) {
186 return !(Lhs < Rhs) && !(Rhs < Lhs);
191 return !(Lhs == Rhs);
220 void convertToArray();
234 MapTy::iterator
end() {
return Map->end(); }
237 MapTy::iterator
erase(MapTy::const_iterator
I) {
return Map->erase(
I); }
240 MapTy::const_iterator Second) {
281 std::vector<std::unique_ptr<DocNode::MapTy>> Maps;
282 std::vector<std::unique_ptr<DocNode::ArrayTy>> Arrays;
283 std::vector<std::unique_ptr<char[]>> Strings;
292 bool HexMode =
false;
298 KindAndDocs[
T] = {
this,
Type(
T)};
380 auto Raw = V.getBuffer();
391 Maps.push_back(std::make_unique<DocNode::MapTy>());
392 N.Map = Maps.back().get();
399 Arrays.push_back(std::make_unique<DocNode::ArrayTy>());
400 N.Array = Arrays.back().get();
440 Strings.push_back(std::unique_ptr<
char[]>(
new char[S.
size()]));
441 memcpy(&Strings.back()[0], S.
data(), S.
size());
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
An efficient, type-erasing, non-owning reference to a callable.
A DocNode that is an array.
void push_back(DocNode N)
DocNode & operator[](size_t Index)
Element access. This extends the array if necessary, with empty nodes.
ArrayTy::iterator begin()
A node in a MsgPack Document.
MapDocNode & getMap(bool Convert=false)
Get a MapDocNode for a map node.
StringRef fromString(StringRef S, StringRef Tag="")
Convert the StringRef and use it to set this DocNode (assuming scalar).
friend bool operator!=(const DocNode &Lhs, const DocNode &Rhs)
Inequality operator.
std::map< DocNode, DocNode > MapTy
ArrayDocNode & getArray(bool Convert=false)
Get an ArrayDocNode for an array node.
MemoryBufferRef getBinary() const
StringRef getString() const
std::string toString() const
Convert this node to a string, assuming it is scalar.
std::vector< DocNode > ArrayTy
DocNode & operator=(const char *Val)
Convenience assignment operators.
friend bool operator==(const DocNode &Lhs, const DocNode &Rhs)
Equality operator.
friend bool operator<(const DocNode &Lhs, const DocNode &Rhs)
Comparison operator, used for map keys.
Document * getDocument() const
Simple in-memory representation of a document of msgpack objects with ability to find and create arra...
bool getHexMode() const
Get Hexmode flag.
DocNode getNode(unsigned V)
Create a UInt node associated with this Document.
DocNode getNode(StringRef V, bool Copy=false)
Create a String node associated with this Document.
DocNode getNode(double V)
Create a Float node associated with this Document.
MapDocNode getMapNode()
Create an empty Map node associated with this Document.
DocNode getEmptyNode()
Create an empty node associated with this Document.
DocNode & getRoot()
Get ref to the document's root element.
DocNode getNode(uint64_t V)
Create a UInt node associated with this Document.
void clear()
Restore the Document to an empty state.
DocNode getNode()
Create a nil node associated with this Document.
ArrayDocNode getArrayNode()
Create an empty Array node associated with this Document.
DocNode getNode(int64_t V)
Create an Int node associated with this Document.
void setHexMode(bool Val=true)
Set whether YAML output uses hex for UInt. Default off.
void toYAML(raw_ostream &OS)
Convert MsgPack Document to YAML text.
DocNode getNode(bool V)
Create a Boolean node associated with this Document.
void writeToBlob(std::string &Blob)
Write a MsgPack document to a binary MsgPack blob.
bool readFromBlob(StringRef Blob, bool Multi, function_ref< int(DocNode *DestNode, DocNode SrcNode, DocNode MapKey)> Merger=[](DocNode *DestNode, DocNode SrcNode, DocNode MapKey) { return -1;})
Read a document from a binary msgpack blob, merging into anything already in the Document.
StringRef addString(StringRef S)
Copy a string into the Document's strings list, and return the copy that is owned by the Document.
DocNode getNode(int V)
Create an Int node associated with this Document.
bool fromYAML(StringRef S)
Read YAML text into the MsgPack document. Returns false on failure.
DocNode getNode(const char *V, bool Copy=false)
Create a String node associated with this Document.
DocNode getNode(MemoryBufferRef V, bool Copy=false)
Create a Binary node associated with this Document.
MapTy::iterator find(DocNode Key)
MapTy::iterator erase(MapTy::const_iterator First, MapTy::const_iterator Second)
size_t erase(DocNode Key)
DocNode & operator[](StringRef S)
Member access.
MapTy::iterator erase(MapTy::const_iterator I)
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
This is an optimization pass for GlobalISel generic memory operations.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
The kind of a DocNode and its owning Document.