14#ifndef LLVM_SUPPORT_LEB128_H
15#define LLVM_SUPPORT_LEB128_H
32 More = !((((
Value == 0 ) && ((Byte & 0x40) == 0)) ||
33 ((
Value == -1) && ((Byte & 0x40) != 0))));
35 if (More || Count < PadTo)
43 for (; Count < PadTo - 1; ++Count)
44 OS <<
char(PadValue | 0x80);
61 More = !((((
Value == 0 ) && ((Byte & 0x40) == 0)) ||
62 ((
Value == -1) && ((Byte & 0x40) != 0))));
64 if (More || Count < PadTo)
72 for (; Count < PadTo - 1; ++Count)
73 *p++ = (PadValue | 0x80);
76 return (
unsigned)(p - orig_p);
88 if (
Value != 0 || Count < PadTo)
95 for (; Count < PadTo - 1; ++Count)
106 unsigned PadTo = 0) {
113 if (
Value != 0 || Count < PadTo)
116 }
while (
Value != 0);
120 for (; Count < PadTo - 1; ++Count)
125 return (
unsigned)(p - orig_p);
134 const char **
error =
nullptr) {
141 *
error =
"malformed uleb128, extends past end";
147 ((Shift == 63 && (Slice << Shift >> Shift) != Slice) ||
148 (Shift > 63 && Slice != 0))) {
150 *
error =
"uleb128 too big for uint64";
154 Value += Slice << Shift;
156 }
while (*p++ >= 128);
168 const char **
error =
nullptr) {
176 *
error =
"malformed sleb128, extends past end";
184 ((Shift == 63 && Slice != 0 && Slice != 0x7f) ||
185 (Shift > 63 && Slice != (
Value < 0 ? 0x7f : 0x00)))) {
187 *
error =
"sleb128 too big for int64";
192 Value |= Slice << Shift;
195 }
while (Byte >= 128);
197 if (Shift < 64 && (Byte & 0x40))
205 const char **
error =
nullptr) {
213 const char **
error =
nullptr) {
227 unsigned MaxLEB128SizeBytes = 16>
229 static_assert(
sizeof(U) == 1,
"Expected buffer of bytes");
230 unsigned LEB128ValueSize;
231 U TmpBuffer[MaxLEB128SizeBytes];
238 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)
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.