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);
132 const char **
error =
nullptr) {
139 *
error =
"malformed uleb128, extends past end";
145 ((Shift == 63 && (Slice << Shift >> Shift) != Slice) ||
146 (Shift > 63 && Slice != 0))) {
148 *
error =
"uleb128 too big for uint64";
152 Value += Slice << Shift;
154 }
while (*p++ >= 128);
166 const char **
error =
nullptr) {
174 *
error =
"malformed sleb128, extends past end";
182 ((Shift == 63 && Slice != 0 && Slice != 0x7f) ||
183 (Shift > 63 && Slice != (
Value < 0 ? 0x7f : 0x00)))) {
185 *
error =
"sleb128 too big for int64";
190 Value |= Slice << Shift;
193 }
while (Byte >= 128);
195 if (Shift < 64 && (Byte & 0x40))
203 const char **
error =
nullptr) {
211 const char **
error =
nullptr) {
224 while (*bufLoc & 0x80) {
225 *bufLoc++ = 0x80 | (val & 0x7f);
235 unsigned MaxLEB128SizeBytes = 16>
237 static_assert(
sizeof(U) == 1,
"Expected buffer of bytes");
238 unsigned LEB128ValueSize;
239 U TmpBuffer[MaxLEB128SizeBytes];
246 Buffer.
append(TmpBuffer, TmpBuffer + LEB128ValueSize);
#define LLVM_UNLIKELY(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.
uint64_t decodeULEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a ULEB128 value.
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.
FunctionAddr VTableAddr Count
LLVM_ABI unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
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)
LLVM_ABI unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.