Go to the documentation of this file.
14 #ifndef LLVM_SUPPORT_LEB128_H
15 #define LLVM_SUPPORT_LEB128_H
28 uint8_t Byte =
Value & 0x7f;
31 More = !((((
Value == 0 ) && ((Byte & 0x40) == 0)) ||
32 ((
Value == -1) && ((Byte & 0x40) != 0))));
34 if (More || Count < PadTo)
41 uint8_t PadValue =
Value < 0 ? 0x7f : 0x00;
42 for (; Count < PadTo - 1; ++Count)
43 OS <<
char(PadValue | 0x80);
57 uint8_t Byte =
Value & 0x7f;
60 More = !((((
Value == 0 ) && ((Byte & 0x40) == 0)) ||
61 ((
Value == -1) && ((Byte & 0x40) != 0))));
63 if (More || Count < PadTo)
70 uint8_t PadValue =
Value < 0 ? 0x7f : 0x00;
71 for (; Count < PadTo - 1; ++Count)
72 *
p++ = (PadValue | 0x80);
75 return (
unsigned)(
p - orig_p);
84 uint8_t Byte =
Value & 0x7f;
87 if (
Value != 0 || Count < PadTo)
94 for (; Count < PadTo - 1; ++Count)
105 unsigned PadTo = 0) {
109 uint8_t Byte =
Value & 0x7f;
112 if (
Value != 0 || Count < PadTo)
115 }
while (
Value != 0);
119 for (; Count < PadTo - 1; ++Count)
124 return (
unsigned)(
p - orig_p);
129 const uint8_t *
end =
nullptr,
130 const char **
error =
nullptr) {
131 const uint8_t *orig_p =
p;
139 *
error =
"malformed uleb128, extends past end";
141 *
n = (unsigned)(
p - orig_p);
145 if ((
Shift >= 64 && Slice != 0) || Slice << Shift >>
Shift != Slice) {
147 *
error =
"uleb128 too big for uint64";
149 *
n = (unsigned)(
p - orig_p);
154 }
while (*
p++ >= 128);
156 *
n = (unsigned)(
p - orig_p);
162 const uint8_t *
end =
nullptr,
163 const char **
error =
nullptr) {
164 const uint8_t *orig_p =
p;
173 *
error =
"malformed sleb128, extends past end";
175 *
n = (unsigned)(
p - orig_p);
180 if ((
Shift >= 64 && Slice != (
Value < 0 ? 0x7f : 0x00)) ||
181 (
Shift == 63 && Slice != 0 && Slice != 0x7f)) {
183 *
error =
"sleb128 too big for int64";
185 *
n = (unsigned)(
p - orig_p);
191 }
while (Byte >= 128);
193 if (
Shift < 64 && (Byte & 0x40))
196 *
n = (unsigned)(
p - orig_p);
208 #endif // LLVM_SUPPORT_LEB128_H
This is an optimization pass for GlobalISel generic memory operations.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
const_iterator end(StringRef path)
Get end iterator over path.
the resulting code requires compare and branches when and if * p
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.
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded 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.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
The same transformation can work with an even modulo with the addition of a and shrink the compare RHS by the same amount Unless the target supports that transformation probably isn t worthwhile The transformation can also easily be made to work with non zero equality for n
LLVM Value Representation.