14#ifndef LLVM_SUPPORT_LEB128_H
15#define LLVM_SUPPORT_LEB128_H
31 More = !((((
Value == 0 ) && ((Byte & 0x40) == 0)) ||
32 ((
Value == -1) && ((Byte & 0x40) != 0))));
34 if (More || Count < PadTo)
42 for (; Count < PadTo - 1; ++Count)
43 OS <<
char(PadValue | 0x80);
60 More = !((((
Value == 0 ) && ((Byte & 0x40) == 0)) ||
61 ((
Value == -1) && ((Byte & 0x40) != 0))));
63 if (More || Count < PadTo)
71 for (; Count < PadTo - 1; ++Count)
72 *p++ = (PadValue | 0x80);
75 return (
unsigned)(p - orig_p);
87 if (
Value != 0 || Count < PadTo)
94 for (; Count < PadTo - 1; ++Count)
105 unsigned PadTo = 0) {
112 if (
Value != 0 || Count < PadTo)
115 }
while (
Value != 0);
119 for (; Count < PadTo - 1; ++Count)
124 return (
unsigned)(p - orig_p);
133 const char **
error =
nullptr) {
140 *
error =
"malformed uleb128, extends past end";
146 ((Shift == 63 && (Slice << Shift >> Shift) != Slice) ||
147 (Shift > 63 && Slice != 0))) {
149 *
error =
"uleb128 too big for uint64";
153 Value += Slice << Shift;
155 }
while (*p++ >= 128);
167 const char **
error =
nullptr) {
175 *
error =
"malformed sleb128, extends past end";
183 ((Shift == 63 && Slice != 0 && Slice != 0x7f) ||
184 (Shift > 63 && Slice != (
Value < 0 ? 0x7f : 0x00)))) {
186 *
error =
"sleb128 too big for int64";
191 Value |= Slice << Shift;
194 }
while (Byte >= 128);
196 if (Shift < 64 && (Byte & 0x40))
204 const char **
error =
nullptr) {
212 const char **
error =
nullptr) {
#define LLVM_UNLIKELY(EXPR)
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)
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.
uint64_t decodeULEB128AndIncUnsafe(const uint8_t *&p)
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.