MCPcopy Create free account
hub / github.com/GANGE666/xVMP / parseConstants

Method parseConstants

src/lib/Bitcode/Reader/BitcodeReader.cpp:2153–2642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2151}
2152
2153Error BitcodeReader::parseConstants() {
2154 if (Stream.EnterSubBlock(bitc::CONSTANTS_BLOCK_ID))
2155 return error("Invalid record");
2156
2157 SmallVector<uint64_t, 64> Record;
2158
2159 // Read all the records for this value table.
2160 Type *CurTy = Type::getInt32Ty(Context);
2161 unsigned NextCstNo = ValueList.size();
2162
2163 while (true) {
2164 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
2165
2166 switch (Entry.Kind) {
2167 case BitstreamEntry::SubBlock: // Handled for us already.
2168 case BitstreamEntry::Error:
2169 return error("Malformed block");
2170 case BitstreamEntry::EndBlock:
2171 if (NextCstNo != ValueList.size())
2172 return error("Invalid constant reference");
2173
2174 // Once all the constants have been read, go through and resolve forward
2175 // references.
2176 ValueList.resolveConstantForwardRefs();
2177 return Error::success();
2178 case BitstreamEntry::Record:
2179 // The interesting case.
2180 break;
2181 }
2182
2183 // Read a record.
2184 Record.clear();
2185 Type *VoidType = Type::getVoidTy(Context);
2186 Value *V = nullptr;
2187 unsigned BitCode = Stream.readRecord(Entry.ID, Record);
2188 switch (BitCode) {
2189 default: // Default behavior: unknown constant
2190 case bitc::CST_CODE_UNDEF: // UNDEF
2191 V = UndefValue::get(CurTy);
2192 break;
2193 case bitc::CST_CODE_SETTYPE: // SETTYPE: [typeid]
2194 if (Record.empty())
2195 return error("Invalid record");
2196 if (Record[0] >= TypeList.size() || !TypeList[Record[0]])
2197 return error("Invalid record");
2198 if (TypeList[Record[0]] == VoidType)
2199 return error("Invalid constant type");
2200 CurTy = TypeList[Record[0]];
2201 continue; // Skip the ValueList manipulation.
2202 case bitc::CST_CODE_NULL: // NULL
2203 V = Constant::getNullValue(CurTy);
2204 break;
2205 case bitc::CST_CODE_INTEGER: // INTEGER: [intval]
2206 if (!CurTy->isIntegerTy() || Record.empty())
2207 return error("Invalid record");
2208 V = ConstantInt::get(CurTy, decodeSignRotatedValue(Record[0]));
2209 break;
2210 case bitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval]

Callers

nothing calls this directly

Calls 15

successFunction · 0.85
getNullValueFunction · 0.85
readWideAPIntFunction · 0.85
getDecodedUnaryOpcodeFunction · 0.85
getDecodedBinaryOpcodeFunction · 0.85
getDecodedCastOpcodeFunction · 0.85
AsmDialectEnum · 0.85
EnterSubBlockMethod · 0.80
isHalfTyMethod · 0.80
isFloatTyMethod · 0.80

Tested by

no test coverage detected