本文整理汇总了C++中llvm::BitstreamWriter::EnterSubblock方法的典型用法代码示例。如果您正苦于以下问题:C++ BitstreamWriter::EnterSubblock方法的具体用法?C++ BitstreamWriter::EnterSubblock怎么用?C++ BitstreamWriter::EnterSubblock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::BitstreamWriter
的用法示例。
在下文中一共展示了BitstreamWriter::EnterSubblock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BLOCK
void
GlobalModuleIndexBuilder::emitBlockInfoBlock(llvm::BitstreamWriter &Stream) {
SmallVector<uint64_t, 64> Record;
Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
#define BLOCK(X) emitBlockID(X ## _ID, #X, Stream, Record)
#define RECORD(X) emitRecordID(X, #X, Stream, Record)
BLOCK(GLOBAL_INDEX_BLOCK);
RECORD(INDEX_METADATA);
RECORD(MODULE);
RECORD(IDENTIFIER_INDEX);
#undef RECORD
#undef BLOCK
Stream.ExitBlock();
}
示例2: writeIndex
void GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
using namespace llvm;
// Emit the file header.
Stream.Emit((unsigned)'B', 8);
Stream.Emit((unsigned)'C', 8);
Stream.Emit((unsigned)'G', 8);
Stream.Emit((unsigned)'I', 8);
// Write the block-info block, which describes the records in this bitcode
// file.
emitBlockInfoBlock(Stream);
Stream.EnterSubblock(GLOBAL_INDEX_BLOCK_ID, 3);
// Write the metadata.
SmallVector<uint64_t, 2> Record;
Record.push_back(CurrentVersion);
Stream.EmitRecord(INDEX_METADATA, Record);
// Write the set of known module files.
for (ModuleFilesMap::iterator M = ModuleFiles.begin(),
MEnd = ModuleFiles.end();
M != MEnd; ++M) {
Record.clear();
Record.push_back(M->second.ID);
Record.push_back(M->first->getSize());
Record.push_back(M->first->getModificationTime());
// File name
StringRef Name(M->first->getName());
Record.push_back(Name.size());
Record.append(Name.begin(), Name.end());
// Dependencies
Record.push_back(M->second.Dependencies.size());
Record.append(M->second.Dependencies.begin(), M->second.Dependencies.end());
Stream.EmitRecord(MODULE, Record);
}
// Write the identifier -> module file mapping.
{
llvm::OnDiskChainedHashTableGenerator<IdentifierIndexWriterTrait> Generator;
IdentifierIndexWriterTrait Trait;
// Populate the hash table.
for (InterestingIdentifierMap::iterator I = InterestingIdentifiers.begin(),
IEnd = InterestingIdentifiers.end();
I != IEnd; ++I) {
Generator.insert(I->first(), I->second, Trait);
}
// Create the on-disk hash table in a buffer.
SmallString<4096> IdentifierTable;
uint32_t BucketOffset;
{
using namespace llvm::support;
llvm::raw_svector_ostream Out(IdentifierTable);
// Make sure that no bucket is at offset 0
endian::Writer<little>(Out).write<uint32_t>(0);
BucketOffset = Generator.Emit(Out, Trait);
}
// Create a blob abbreviation
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(IDENTIFIER_INDEX));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned IDTableAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the identifier table
Record.clear();
Record.push_back(IDENTIFIER_INDEX);
Record.push_back(BucketOffset);
Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable.str());
}
Stream.ExitBlock();
}
示例3: writeIndex
bool GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
for (auto MapEntry : ImportedModuleFiles) {
auto *File = MapEntry.first;
ImportedModuleFileInfo &Info = MapEntry.second;
if (getModuleFileInfo(File).Signature) {
if (getModuleFileInfo(File).Signature != Info.StoredSignature)
// Verify Signature.
return true;
} else if (Info.StoredSize != File->getSize() ||
Info.StoredModTime != File->getModificationTime())
// Verify Size and ModTime.
return true;
}
using namespace llvm;
llvm::TimeTraceScope TimeScope("Module WriteIndex", StringRef(""));
// Emit the file header.
Stream.Emit((unsigned)'B', 8);
Stream.Emit((unsigned)'C', 8);
Stream.Emit((unsigned)'G', 8);
Stream.Emit((unsigned)'I', 8);
// Write the block-info block, which describes the records in this bitcode
// file.
emitBlockInfoBlock(Stream);
Stream.EnterSubblock(GLOBAL_INDEX_BLOCK_ID, 3);
// Write the metadata.
SmallVector<uint64_t, 2> Record;
Record.push_back(CurrentVersion);
Stream.EmitRecord(INDEX_METADATA, Record);
// Write the set of known module files.
for (ModuleFilesMap::iterator M = ModuleFiles.begin(),
MEnd = ModuleFiles.end();
M != MEnd; ++M) {
Record.clear();
Record.push_back(M->second.ID);
Record.push_back(M->first->getSize());
Record.push_back(M->first->getModificationTime());
// File name
StringRef Name(M->first->getName());
Record.push_back(Name.size());
Record.append(Name.begin(), Name.end());
// Dependencies
Record.push_back(M->second.Dependencies.size());
Record.append(M->second.Dependencies.begin(), M->second.Dependencies.end());
Stream.EmitRecord(MODULE, Record);
}
// Write the identifier -> module file mapping.
{
llvm::OnDiskChainedHashTableGenerator<IdentifierIndexWriterTrait> Generator;
IdentifierIndexWriterTrait Trait;
// Populate the hash table.
for (InterestingIdentifierMap::iterator I = InterestingIdentifiers.begin(),
IEnd = InterestingIdentifiers.end();
I != IEnd; ++I) {
Generator.insert(I->first(), I->second, Trait);
}
// Create the on-disk hash table in a buffer.
SmallString<4096> IdentifierTable;
uint32_t BucketOffset;
{
using namespace llvm::support;
llvm::raw_svector_ostream Out(IdentifierTable);
// Make sure that no bucket is at offset 0
endian::write<uint32_t>(Out, 0, little);
BucketOffset = Generator.Emit(Out, Trait);
}
// Create a blob abbreviation
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(IDENTIFIER_INDEX));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned IDTableAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
// Write the identifier table
uint64_t Record[] = {IDENTIFIER_INDEX, BucketOffset};
Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
}
Stream.ExitBlock();
return false;
}