MCPcopy Create free account
hub / github.com/NVIDIA/cuda-tile / readVarInt

Method readVarInt

lib/Bytecode/Reader/BytecodeReader.cpp:94–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 : data(data), offset(0), context(context) {}
93
94 LogicalResult readVarInt(uint64_t &result, uint64_t max = 0) {
95 if (offset >= data.size())
96 return failure();
97 result = 0;
98 uint64_t shift = 0;
99 uint8_t byte;
100 do {
101 if (offset >= data.size() || shift > 63)
102 return failure();
103 byte = data[offset++];
104 uint64_t value = byte & 0x7F;
105 result |= (value << shift);
106 shift += 7;
107 } while (byte & 0x80);
108 if (max && result > max)
109 return emitError() << "varint value exceeds maximum supported"
110 << " capacity. (expected value less than " << max
111 << ", got " << result << ").";
112 return success();
113 }
114
115 /// Parse a signed variable length encoded integer from the byte stream. A
116 /// signed varint is encoded as a normal varint with zigzag encoding applied,

Callers 15

parseSectionHeaderFunction · 0.80
parseStringSectionFunction · 0.80
parseGenericEnumAttrFunction · 0.80
getTypeMethod · 0.80
readAndGetTypeMethod · 0.80
parseFunctionTypeMethod · 0.80
parseTypeSectionFunction · 0.80
getOrCreateMethod · 0.80
parseConstantSectionFunction · 0.80
readAndGetDebugInfoMethod · 0.80
getDebugInfoMethod · 0.80
parseDILexicalBlockMethod · 0.80

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected