22 : EW(OS,
Endianness), Compatible(Compatible) {}
26 void Writer::write(
bool b) { EW.write(b ? FirstByte::True : FirstByte::False); }
30 write(static_cast<uint64_t>(i));
34 if (i >= FixMin::NegativeInt) {
35 EW.write(static_cast<int8_t>(i));
41 EW.write(static_cast<int8_t>(i));
46 EW.write(FirstByte::Int16);
47 EW.write(static_cast<int16_t>(i));
52 EW.write(FirstByte::Int32);
53 EW.write(static_cast<int32_t>(i));
57 EW.write(FirstByte::Int64);
62 if (u <= FixMax::PositiveInt) {
63 EW.write(static_cast<uint8_t>(u));
69 EW.write(static_cast<uint8_t>(u));
73 if (u <= UINT16_MAX) {
74 EW.write(FirstByte::UInt16);
75 EW.write(static_cast<uint16_t>(u));
79 if (u <= UINT32_MAX) {
80 EW.write(FirstByte::UInt32);
81 EW.write(static_cast<uint32_t>(u));
85 EW.write(FirstByte::UInt64);
92 if (a >= std::numeric_limits<float>::min() &&
94 EW.write(FirstByte::Float32);
95 EW.write(static_cast<float>(d));
97 EW.write(FirstByte::Float64);
105 if (Size <= FixMax::String)
106 EW.write(static_cast<uint8_t>(FixBits::String | Size));
107 else if (!Compatible && Size <= UINT8_MAX) {
108 EW.write(FirstByte::Str8);
109 EW.write(static_cast<uint8_t>(Size));
110 }
else if (Size <= UINT16_MAX) {
111 EW.write(FirstByte::Str16);
112 EW.write(static_cast<uint16_t>(Size));
114 assert(Size <= UINT32_MAX &&
"String object too long to be encoded");
115 EW.write(FirstByte::Str32);
116 EW.write(static_cast<uint32_t>(Size));
123 assert(!Compatible &&
"Attempt to write Bin format in compatible mode");
127 if (Size <= UINT8_MAX) {
128 EW.write(FirstByte::Bin8);
129 EW.write(static_cast<uint8_t>(Size));
130 }
else if (Size <= UINT16_MAX) {
131 EW.write(FirstByte::Bin16);
132 EW.write(static_cast<uint16_t>(Size));
134 assert(Size <= UINT32_MAX &&
"Binary object too long to be encoded");
135 EW.write(FirstByte::Bin32);
136 EW.write(static_cast<uint32_t>(Size));
143 if (Size <= FixMax::Array) {
144 EW.write(static_cast<uint8_t>(FixBits::Array | Size));
148 if (Size <= UINT16_MAX) {
149 EW.write(FirstByte::Array16);
150 EW.write(static_cast<uint16_t>(Size));
154 EW.write(FirstByte::Array32);
159 if (Size <= FixMax::Map) {
160 EW.write(static_cast<uint8_t>(FixBits::Map | Size));
164 if (Size <= UINT16_MAX) {
165 EW.write(FirstByte::Map16);
166 EW.write(static_cast<uint16_t>(Size));
170 EW.write(FirstByte::Map32);
179 EW.write(FirstByte::FixExt1);
182 EW.write(FirstByte::FixExt2);
185 EW.write(FirstByte::FixExt4);
188 EW.write(FirstByte::FixExt8);
191 EW.write(FirstByte::FixExt16);
194 if (Size <= UINT8_MAX) {
195 EW.write(FirstByte::Ext8);
196 EW.write(static_cast<uint8_t>(Size));
197 }
else if (Size <= UINT16_MAX) {
198 EW.write(FirstByte::Ext16);
199 EW.write(static_cast<uint16_t>(Size));
201 assert(Size <= UINT32_MAX &&
"Ext size too large to be encoded");
202 EW.write(FirstByte::Ext32);
203 EW.write(static_cast<uint32_t>(Size));
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
void writeExt(int8_t Type, MemoryBufferRef Buffer)
Write a typed memory buffer (an extension type) to the output stream.
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
void writeMapSize(uint32_t Size)
Write the header for a Map of the given size.
Writer(raw_ostream &OS, bool Compatible=false)
Construct a writer, optionally enabling "Compatibility Mode" as defined in the MessagePack specificat...
void writeNil()
Write a Nil to the output stream.
size_t getBufferSize() const
void writeArraySize(uint32_t Size)
Write the header for an Array of the given size.
void write(Writer &MPWriter) override
Write to a MessagePack writer MPWriter.
void write(bool b)
Write a Boolean to the output stream.
This file contains constants used for implementing MessagePack support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const char * getBufferStart() const
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
This file contains a MessagePack writer.