15 #ifndef LLVM_SUPPORT_LEB128_H
16 #define LLVM_SUPPORT_LEB128_H
26 uint8_t Byte = Value & 0x7f;
29 More = !((((Value == 0 ) && ((Byte & 0x40) == 0)) ||
30 ((Value == -1) && ((Byte & 0x40) != 0))));
39 unsigned Padding = 0) {
41 uint8_t Byte = Value & 0x7f;
43 if (Value != 0 || Padding != 0)
50 for (; Padding != 1; --Padding)
59 unsigned Padding = 0) {
62 uint8_t Byte = Value & 0x7f;
64 if (Value != 0 || Padding != 0)
71 for (; Padding != 1; --Padding)
75 return (
unsigned)(p - orig_p);
80 inline uint64_t
decodeULEB128(
const uint8_t *p,
unsigned *n =
nullptr) {
81 const uint8_t *orig_p = p;
85 Value += uint64_t(*p & 0x7f) << Shift;
87 }
while (*p++ >= 128);
95 const uint8_t *orig_p = p;
101 Value |= ((Byte & 0x7f) << Shift);
103 }
while (Byte >= 128);
106 Value |= (-1ULL) << Shift;
121 #endif // LLVM_SYSTEM_LEB128_H
uint64_t decodeULEB128(const uint8_t *p, unsigned *n=nullptr)
Utility function to decode a ULEB128 value.
int64_t decodeSLEB128(const uint8_t *p, unsigned *n=nullptr)
Utility function to decode a SLEB128 value.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void encodeSLEB128(int64_t Value, raw_ostream &OS)
Utility function to encode a SLEB128 value to an output stream.
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
void encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned Padding=0)
Utility function to encode a ULEB128 value to an output stream.