14#ifndef LLVM_SUPPORT_LEB128_H
15#define LLVM_SUPPORT_LEB128_H
32 More =
Value != ((Byte & 0x40) ? -1 : 0);
34 if (More ||
Count < PadTo)
43 OS <<
char(PadValue | 0x80);
60 More =
Value != ((Byte & 0x40) ? -1 : 0);
62 if (More ||
Count < PadTo)
71 *p++ = (PadValue | 0x80);
74 return (
unsigned)(p - orig_p);
104 unsigned PadTo = 0) {
114 }
while (
Value != 0);
123 return (
unsigned)(p - orig_p);
157 *
error =
"malformed uleb128, extends past end";
165 ((Shift == 63 && (Slice << Shift >> Shift) != Slice) ||
166 (Shift > 63 && Slice != 0))) {
168 *
error =
"uleb128 too big for uint64";
179 Value += Slice << Shift;
181 }
while (*p++ >= 128);
195 const char **
error =
nullptr) {
205 const char **
error =
nullptr) {
213 *
error =
"malformed sleb128, extends past end";
221 ((Shift == 63 && Slice != 0 && Slice != 0x7f) ||
222 (Shift > 63 && Slice != (
Value < 0 ? 0x7f : 0x00)))) {
224 *
error =
"sleb128 too big for int64";
234 Value |= Slice << Shift;
237 }
while (Byte >= 128);
239 if (Shift < 64 && (Byte & 0x40))
247 const char **
error =
nullptr) {
255 const char **
error =
nullptr) {
268 while (*bufLoc & 0x80) {
269 *bufLoc++ = 0x80 | (val & 0x7f);
279 unsigned MaxLEB128SizeBytes = 16>
281 static_assert(
sizeof(U) == 1,
"Expected buffer of bytes");
282 unsigned LEB128ValueSize;
283 U TmpBuffer[MaxLEB128SizeBytes];
290 Buffer.
append(TmpBuffer, TmpBuffer + LEB128ValueSize);
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
ULEB128DecodeError
Identifies why ULEB128 decoding failed.
@ UnexpectedEnd
The encoding requires bytes beyond the supplied buffer.
@ None
No decoding error has been reported.
@ TooBig
The encoded value does not fit in uint64_t.
int64_t decodeSLEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a SLEB128 value.
int64_t decodeSLEB128AndInc(const uint8_t *&p, const uint8_t *end, const char **error=nullptr)
uint64_t decodeULEB128AndInc(const uint8_t *&p, const uint8_t *end, const char **error=nullptr)
uint64_t overwriteULEB128(uint8_t *bufLoc, uint64_t val)
Overwrite a ULEB128 value and keep the original length.
LLVM_ABI unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
void appendLEB128(SmallVectorImpl< U > &Buffer, T Value)
uint64_t decodeULEB128AndIncUnsafe(const uint8_t *&p)
uint64_t decodeULEB128(const uint8_t *p, unsigned *n, const uint8_t *end, const char **error, ULEB128DecodeError *errorCode)
Utility function to decode a ULEB128 value and report a typed error.
LLVM_ABI unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.