diff options
Diffstat (limited to 'source/slang/ir-serialize.cpp')
| -rw-r--r-- | source/slang/ir-serialize.cpp | 260 |
1 files changed, 130 insertions, 130 deletions
diff --git a/source/slang/ir-serialize.cpp b/source/slang/ir-serialize.cpp index a50ed6bd5..33238a9a6 100644 --- a/source/slang/ir-serialize.cpp +++ b/source/slang/ir-serialize.cpp @@ -81,7 +81,7 @@ void StringRepresentationCache::init(const List<char>* stringTable, NamePool* na m_scopeManager = scopeManager; // Decode the table - m_entries.SetSize(StringSlicePool::kNumDefaultHandles); + m_entries.setCount(StringSlicePool::kNumDefaultHandles); SLANG_COMPILE_TIME_ASSERT(StringSlicePool::kNumDefaultHandles == 2); { @@ -112,13 +112,13 @@ void StringRepresentationCache::init(const List<char>* stringTable, NamePool* na entry.m_numChars = len; entry.m_object = nullptr; - m_entries.Add(entry); + m_entries.add(entry); cur = reader.m_pos + len; } } - m_entries.Compress(); + m_entries.compress(); } Name* StringRepresentationCache::getName(Handle handle) @@ -209,7 +209,7 @@ char* StringRepresentationCache::getCStr(Handle handle) /* static */void SerialStringTableUtil::encodeStringTable(const UnownedStringSlice* slices, size_t numSlices, List<char>& stringTable) { - stringTable.Clear(); + stringTable.clear(); for (size_t i = 0; i < numSlices; ++i) { const UnownedStringSlice slice = slices[i]; @@ -218,9 +218,9 @@ char* StringRepresentationCache::getCStr(Handle handle) // We need to write into the the string array char prefixBytes[6]; const int numPrefixBytes = EncodeUnicodePointToUTF8(prefixBytes, len); - const int baseIndex = int(stringTable.Count()); + const Index baseIndex = stringTable.getCount(); - stringTable.SetSize(baseIndex + numPrefixBytes + len); + stringTable.setCount(baseIndex + numPrefixBytes + len); char* dst = stringTable.begin() + baseIndex; @@ -239,14 +239,14 @@ char* StringRepresentationCache::getCStr(Handle handle) { CharReader reader(cur); const int len = GetUnicodePointFromUTF8(reader); - slicesOut.Add(UnownedStringSlice(reader.m_pos, len)); + slicesOut.add(UnownedStringSlice(reader.m_pos, len)); cur = reader.m_pos + len; } } /* static */void SerialStringTableUtil::decodeStringTable(const List<char>& stringTable, List<UnownedStringSlice>& slicesOut) { - slicesOut.SetSize(2); + slicesOut.setCount(2); slicesOut[0] = UnownedStringSlice(nullptr, size_t(0)); slicesOut[1] = UnownedStringSlice("", size_t(0)); @@ -255,19 +255,19 @@ char* StringRepresentationCache::getCStr(Handle handle) /* static */void SerialStringTableUtil::calcStringSlicePoolMap(const List<UnownedStringSlice>& slices, StringSlicePool& pool, List<StringSlicePool::Handle>& indexMapOut) { - SLANG_ASSERT(slices.Count() >= StringSlicePool::kNumDefaultHandles); + SLANG_ASSERT(slices.getCount() >= StringSlicePool::kNumDefaultHandles); SLANG_ASSERT(slices[int(StringSlicePool::kNullHandle)] == "" && slices[int(StringSlicePool::kNullHandle)].begin() == nullptr); SLANG_ASSERT(slices[int(StringSlicePool::kEmptyHandle)] == ""); - indexMapOut.SetSize(slices.Count()); + indexMapOut.setCount(slices.getCount()); // Set up all of the defaults for (int i = 0; i < StringSlicePool::kNumDefaultHandles; ++i) { indexMapOut[i] = StringSlicePool::Handle(i); } - const int numSlices = int(slices.Count()); - for (int i = StringSlicePool::kNumDefaultHandles; i < numSlices ; ++i) + const Index numSlices = slices.getCount(); + for (Index i = StringSlicePool::kNumDefaultHandles; i < numSlices ; ++i) { indexMapOut[i] = pool.add(slices[i]); } @@ -278,7 +278,7 @@ char* StringRepresentationCache::getCStr(Handle handle) template<typename T> static size_t _calcArraySize(const List<T>& list) { - return list.Count() * sizeof(T); + return list.getCount() * sizeof(T); } size_t IRSerialData::calcSizeInBytes() const @@ -306,32 +306,32 @@ IRSerialData::IRSerialData() void IRSerialData::clear() { // First Instruction is null - m_insts.SetSize(1); + m_insts.setCount(1); memset(&m_insts[0], 0, sizeof(Inst)); - m_childRuns.Clear(); - m_externalOperands.Clear(); - m_rawSourceLocs.Clear(); + m_childRuns.clear(); + m_externalOperands.clear(); + m_rawSourceLocs.clear(); - m_stringTable.Clear(); + m_stringTable.clear(); // Debug data - m_debugLineInfos.Clear(); - m_debugAdjustedLineInfos.Clear(); - m_debugSourceInfos.Clear(); - m_debugSourceLocRuns.Clear(); - m_debugStringTable.Clear(); + m_debugLineInfos.clear(); + m_debugAdjustedLineInfos.clear(); + m_debugSourceInfos.clear(); + m_debugSourceLocRuns.clear(); + m_debugStringTable.clear(); } template <typename T> static bool _isEqual(const List<T>& aIn, const List<T>& bIn) { - if (aIn.Count() != bIn.Count()) + if (aIn.getCount() != bIn.getCount()) { return false; } - size_t size = size_t(aIn.Count()); + size_t size = size_t(aIn.getCount()); const T* a = aIn.begin(); const T* b = bIn.begin(); @@ -376,8 +376,8 @@ void IRSerialWriter::_addInstruction(IRInst* inst) SLANG_ASSERT(!m_instMap.ContainsKey(inst)); // Add to the map - m_instMap.Add(inst, Ser::InstIndex(m_insts.Count())); - m_insts.Add(inst); + m_instMap.Add(inst, Ser::InstIndex(m_insts.getCount())); + m_insts.add(inst); } #if 0 @@ -444,7 +444,7 @@ void IRSerialWriter::_addDebugSourceLocRun(SourceLoc sourceLoc, uint32_t startIn int entryIndex = sourceView->findEntryIndex(sourceLoc); if (entryIndex < 0) { - debugSourceFile->m_lineInfos.Add(lineInfo); + debugSourceFile->m_lineInfos.add(lineInfo); } else { @@ -463,7 +463,7 @@ void IRSerialWriter::_addDebugSourceLocRun(SourceLoc sourceLoc, uint32_t startIn adjustedLineInfo.m_adjustedLineIndex = lineIndex + entry.m_lineAdjust; - debugSourceFile->m_adjustedLineInfos.Add(adjustedLineInfo); + debugSourceFile->m_adjustedLineInfos.add(adjustedLineInfo); } debugSourceFile->setHasLineIndex(lineIndex); @@ -475,7 +475,7 @@ void IRSerialWriter::_addDebugSourceLocRun(SourceLoc sourceLoc, uint32_t startIn sourceLocRun.m_startInstIndex = IRSerialData::InstIndex(startInstIndex); sourceLocRun.m_sourceLoc = uint32_t(debugSourceFile->m_baseSourceLoc + offset); - m_serialData->m_debugSourceLocRuns.Add(sourceLocRun); + m_serialData->m_debugSourceLocRuns.add(sourceLocRun); } Result IRSerialWriter::_calcDebugInfo() @@ -497,8 +497,8 @@ Result IRSerialWriter::_calcDebugInfo() // Find all of the source locations and their associated instructions List<InstLoc> instLocs; - const int numInsts = int(m_insts.Count()); - for (int i = 1; i < numInsts; i++) + const Index numInsts = m_insts.getCount(); + for (Index i = 1; i < numInsts; i++) { IRInst* srcInst = m_insts[i]; if (!srcInst->sourceLoc.isValid()) @@ -508,11 +508,11 @@ Result IRSerialWriter::_calcDebugInfo() InstLoc instLoc; instLoc.instIndex = uint32_t(i); instLoc.sourceLoc = uint32_t(srcInst->sourceLoc.getRaw()); - instLocs.Add(instLoc); + instLocs.add(instLoc); } // Sort them - instLocs.Sort(); + instLocs.sort(); m_debugFreeSourceLoc = 1; // Look for runs @@ -549,25 +549,25 @@ Result IRSerialWriter::_calcDebugInfo() IRSerialData::DebugSourceInfo sourceInfo; - sourceInfo.m_numLines = uint32_t(debugSourceFile->m_sourceFile->getLineBreakOffsets().Count()); + sourceInfo.m_numLines = uint32_t(debugSourceFile->m_sourceFile->getLineBreakOffsets().getCount()); sourceInfo.m_startSourceLoc = uint32_t(debugSourceFile->m_baseSourceLoc); sourceInfo.m_endSourceLoc = uint32_t(debugSourceFile->m_baseSourceLoc + sourceFile->getContentSize()); sourceInfo.m_pathIndex = Ser::StringIndex(m_debugStringSlicePool.add(sourceFile->getPathInfo().foundPath)); - sourceInfo.m_lineInfosStartIndex = uint32_t(m_serialData->m_debugLineInfos.Count()); - sourceInfo.m_adjustedLineInfosStartIndex = uint32_t(m_serialData->m_debugAdjustedLineInfos.Count()); + sourceInfo.m_lineInfosStartIndex = uint32_t(m_serialData->m_debugLineInfos.getCount()); + sourceInfo.m_adjustedLineInfosStartIndex = uint32_t(m_serialData->m_debugAdjustedLineInfos.getCount()); - sourceInfo.m_numLineInfos = uint32_t(debugSourceFile->m_lineInfos.Count()); - sourceInfo.m_numAdjustedLineInfos = uint32_t(debugSourceFile->m_adjustedLineInfos.Count()); + sourceInfo.m_numLineInfos = uint32_t(debugSourceFile->m_lineInfos.getCount()); + sourceInfo.m_numAdjustedLineInfos = uint32_t(debugSourceFile->m_adjustedLineInfos.getCount()); // Add the line infos - m_serialData->m_debugLineInfos.AddRange(debugSourceFile->m_lineInfos.begin(), debugSourceFile->m_lineInfos.Count()); - m_serialData->m_debugAdjustedLineInfos.AddRange(debugSourceFile->m_adjustedLineInfos.begin(), debugSourceFile->m_adjustedLineInfos.Count()); + m_serialData->m_debugLineInfos.addRange(debugSourceFile->m_lineInfos.begin(), debugSourceFile->m_lineInfos.getCount()); + m_serialData->m_debugAdjustedLineInfos.addRange(debugSourceFile->m_adjustedLineInfos.begin(), debugSourceFile->m_adjustedLineInfos.getCount()); // Add the source info - m_serialData->m_debugSourceInfos.Add(sourceInfo); + m_serialData->m_debugSourceInfos.add(sourceInfo); } // Convert the string pool @@ -586,33 +586,33 @@ Result IRSerialWriter::write(IRModule* module, SourceManager* sourceManager, Opt serialData->clear(); // We reserve 0 for null - m_insts.Clear(); - m_insts.Add(nullptr); + m_insts.clear(); + m_insts.add(nullptr); // Reset m_instMap.Clear(); - m_decorations.Clear(); + m_decorations.clear(); // Stack for parentInst List<IRInst*> parentInstStack; IRModuleInst* moduleInst = module->getModuleInst(); - parentInstStack.Add(moduleInst); + parentInstStack.add(moduleInst); // Add to the map _addInstruction(moduleInst); // Traverse all of the instructions - while (parentInstStack.Count()) + while (parentInstStack.getCount()) { // If it's in the stack it is assumed it is already in the inst map - IRInst* parentInst = parentInstStack.Last(); - parentInstStack.RemoveLast(); + IRInst* parentInst = parentInstStack.getLast(); + parentInstStack.removeLast(); SLANG_ASSERT(m_instMap.ContainsKey(parentInst)); // Okay we go through each of the children in order. If they are IRInstParent derived, we add to stack to process later // cos we want breadth first so the order of children is the same as their index order, meaning we don't need to store explicit indices - const Ser::InstIndex startChildInstIndex = Ser::InstIndex(m_insts.Count()); + const Ser::InstIndex startChildInstIndex = Ser::InstIndex(m_insts.getCount()); IRInstListBase childrenList = parentInst->getDecorationsAndChildren(); for (IRInst* child : childrenList) @@ -622,18 +622,18 @@ Result IRSerialWriter::write(IRModule* module, SourceManager* sourceManager, Opt _addInstruction(child); - parentInstStack.Add(child); + parentInstStack.add(child); } // If it had any children, then store the information about it - if (Ser::InstIndex(m_insts.Count()) != startChildInstIndex) + if (Ser::InstIndex(m_insts.getCount()) != startChildInstIndex) { Ser::InstRun run; run.m_parentIndex = m_instMap[parentInst]; run.m_startInstIndex = startChildInstIndex; - run.m_numChildren = Ser::SizeType(m_insts.Count() - int(startChildInstIndex)); + run.m_numChildren = Ser::SizeType(m_insts.getCount() - int(startChildInstIndex)); - m_serialData->m_childRuns.Add(run); + m_serialData->m_childRuns.add(run); } } @@ -650,15 +650,15 @@ Result IRSerialWriter::write(IRModule* module, SourceManager* sourceManager, Opt #endif // Set to the right size - m_serialData->m_insts.SetSize(m_insts.Count()); + m_serialData->m_insts.setCount(m_insts.getCount()); // Clear all instructions - memset(m_serialData->m_insts.begin(), 0, sizeof(Ser::Inst) * m_serialData->m_insts.Count()); + memset(m_serialData->m_insts.begin(), 0, sizeof(Ser::Inst) * m_serialData->m_insts.getCount()); // Need to set up the actual instructions { - const int numInsts = int(m_insts.Count()); + const Index numInsts = m_insts.getCount(); - for (int i = 1; i < numInsts; ++i) + for (Index i = 1; i < numInsts; ++i) { IRInst* srcInst = m_insts[i]; Ser::Inst& dstInst = m_serialData->m_insts[i]; @@ -744,8 +744,8 @@ Result IRSerialWriter::write(IRModule* module, SourceManager* sourceManager, Opt { dstInst.m_payloadType = PayloadType::OperandExternal; - int operandArrayBaseIndex = int(m_serialData->m_externalOperands.Count()); - m_serialData->m_externalOperands.SetSize(operandArrayBaseIndex + numOperands); + int operandArrayBaseIndex = int(m_serialData->m_externalOperands.getCount()); + m_serialData->m_externalOperands.setCount(operandArrayBaseIndex + numOperands); dstOperands = m_serialData->m_externalOperands.begin() + operandArrayBaseIndex; @@ -770,13 +770,13 @@ Result IRSerialWriter::write(IRModule* module, SourceManager* sourceManager, Opt // If the option to use RawSourceLocations is enabled, serialize out as is if (options & OptionFlag::RawSourceLocation) { - const int numInsts = int(m_insts.Count()); - serialData->m_rawSourceLocs.SetSize(numInsts); + const Index numInsts = m_insts.getCount(); + serialData->m_rawSourceLocs.setCount(numInsts); Ser::RawSourceLoc* dstLocs = serialData->m_rawSourceLocs.begin(); // 0 is null, just mark as no location dstLocs[0] = Ser::RawSourceLoc(0); - for (int i = 1; i < numInsts; ++i) + for (Index i = 1; i < numInsts; ++i) { IRInst* srcInst = m_insts[i]; dstLocs[i] = Ser::RawSourceLoc(srcInst->sourceLoc.getRaw()); @@ -797,18 +797,18 @@ static size_t _calcChunkSize(IRSerialBinary::CompressionType compressionType, co { typedef IRSerialBinary Bin; - if (array.Count()) + if (array.getCount()) { switch (compressionType) { case Bin::CompressionType::None: { - const size_t size = sizeof(Bin::ArrayHeader) + sizeof(T) * array.Count(); + const size_t size = sizeof(Bin::ArrayHeader) + sizeof(T) * array.getCount(); return (size + 3) & ~size_t(3); } case Bin::CompressionType::VariableByteLite: { - const size_t payloadSize = ByteEncodeUtil::calcEncodeLiteSizeUInt32((const uint32_t*)array.begin(), (array.Count() * sizeof(T)) / sizeof(uint32_t)); + const size_t payloadSize = ByteEncodeUtil::calcEncodeLiteSizeUInt32((const uint32_t*)array.begin(), (array.getCount() * sizeof(T)) / sizeof(uint32_t)); const size_t size = sizeof(Bin::CompressedArrayHeader) + payloadSize; return (size + 3) & ~size_t(3); } @@ -860,7 +860,7 @@ static Result _writeArrayChunk(IRSerialBinary::CompressionType compressionType, ByteEncodeUtil::encodeLiteUInt32((const uint32_t*)data, numCompressedEntries, compressedPayload); - payloadSize = sizeof(Bin::CompressedArrayHeader) - sizeof(Bin::Chunk) + compressedPayload.Count(); + payloadSize = sizeof(Bin::CompressedArrayHeader) - sizeof(Bin::Chunk) + compressedPayload.getCount(); Bin::CompressedArrayHeader header; header.m_chunk.m_type = SLANG_MAKE_COMPRESSED_FOUR_CC(chunkId); @@ -870,7 +870,7 @@ static Result _writeArrayChunk(IRSerialBinary::CompressionType compressionType, stream->Write(&header, sizeof(header)); - stream->Write(compressedPayload.begin(), compressedPayload.Count()); + stream->Write(compressedPayload.begin(), compressedPayload.getCount()); break; } default: @@ -893,7 +893,7 @@ static Result _writeArrayChunk(IRSerialBinary::CompressionType compressionType, template <typename T> Result _writeArrayChunk(IRSerialBinary::CompressionType compressionType, uint32_t chunkId, const List<T>& array, Stream* stream) { - return _writeArrayChunk(compressionType, chunkId, array.begin(), size_t(array.Count()), sizeof(T), stream); + return _writeArrayChunk(compressionType, chunkId, array.begin(), size_t(array.getCount()), sizeof(T), stream); } Result _encodeInsts(IRSerialBinary::CompressionType compressionType, const List<IRSerialData::Inst>& instsIn, List<uint8_t>& encodeArrayOut) @@ -905,9 +905,9 @@ Result _encodeInsts(IRSerialBinary::CompressionType compressionType, const List< { return SLANG_FAIL; } - encodeArrayOut.Clear(); + encodeArrayOut.clear(); - const size_t numInsts = size_t(instsIn.Count()); + const size_t numInsts = size_t(instsIn.getCount()); const IRSerialData::Inst* insts = instsIn.begin(); uint8_t* encodeOut = encodeArrayOut.begin(); @@ -927,11 +927,11 @@ Result _encodeInsts(IRSerialBinary::CompressionType compressionType, const List< { const size_t offset = size_t(encodeOut - encodeArrayOut.begin()); - const UInt oldCapacity = encodeArrayOut.Capacity(); + const UInt oldCapacity = encodeArrayOut.getCapacity(); - encodeArrayOut.Reserve(oldCapacity + (oldCapacity >> 1) + maxInstSize); - const UInt capacity = encodeArrayOut.Capacity(); - encodeArrayOut.SetSize(capacity); + encodeArrayOut.reserve(oldCapacity + (oldCapacity >> 1) + maxInstSize); + const UInt capacity = encodeArrayOut.getCapacity(); + encodeArrayOut.setCount(capacity); encodeOut = encodeArrayOut.begin() + offset; encodeEnd = encodeArrayOut.end(); @@ -982,14 +982,14 @@ Result _encodeInsts(IRSerialBinary::CompressionType compressionType, const List< } // Fix the size - encodeArrayOut.SetSize(UInt(encodeOut - encodeArrayOut.begin())); + encodeArrayOut.setCount(UInt(encodeOut - encodeArrayOut.begin())); return SLANG_OK; } Result _writeInstArrayChunk(IRSerialBinary::CompressionType compressionType, uint32_t chunkId, const List<IRSerialData::Inst>& array, Stream* stream) { typedef IRSerialBinary Bin; - if (array.Count() == 0) + if (array.getCount() == 0) { return SLANG_OK; } @@ -1005,16 +1005,16 @@ Result _writeInstArrayChunk(IRSerialBinary::CompressionType compressionType, uin List<uint8_t> compressedPayload; SLANG_RETURN_ON_FAIL(_encodeInsts(compressionType, array, compressedPayload)); - size_t payloadSize = sizeof(Bin::CompressedArrayHeader) - sizeof(Bin::Chunk) + compressedPayload.Count(); + size_t payloadSize = sizeof(Bin::CompressedArrayHeader) - sizeof(Bin::Chunk) + compressedPayload.getCount(); Bin::CompressedArrayHeader header; header.m_chunk.m_type = SLANG_MAKE_COMPRESSED_FOUR_CC(chunkId); header.m_chunk.m_size = uint32_t(payloadSize); - header.m_numEntries = uint32_t(array.Count()); + header.m_numEntries = uint32_t(array.getCount()); header.m_numCompressedEntries = 0; stream->Write(&header, sizeof(header)); - stream->Write(compressedPayload.begin(), compressedPayload.Count()); + stream->Write(compressedPayload.begin(), compressedPayload.getCount()); // All chunks have sizes rounded to dword size if (payloadSize & 3) @@ -1046,7 +1046,7 @@ static size_t _calcInstChunkSize(IRSerialBinary::CompressionType compressionType { size_t size = sizeof(Bin::CompressedArrayHeader); - size_t numInsts = size_t(instsIn.Count()); + size_t numInsts = size_t(instsIn.getCount()); size += numInsts * 2; // op and payload IRSerialData::Inst* insts = instsIn.begin(); @@ -1114,7 +1114,7 @@ static size_t _calcInstChunkSize(IRSerialBinary::CompressionType compressionType _calcChunkSize(Bin::CompressionType::None, data.m_stringTable) + _calcChunkSize(Bin::CompressionType::None, data.m_rawSourceLocs); - if (data.m_debugSourceInfos.Count()) + if (data.m_debugSourceInfos.getCount()) { totalSize += _calcChunkSize(Bin::CompressionType::None, data.m_debugStringTable) + _calcChunkSize(Bin::CompressionType::None, data.m_debugLineInfos) + @@ -1146,7 +1146,7 @@ static size_t _calcInstChunkSize(IRSerialBinary::CompressionType compressionType SLANG_RETURN_ON_FAIL(_writeArrayChunk(Bin::CompressionType::None, Bin::kUInt32SourceLocFourCc, data.m_rawSourceLocs, stream)); - if (data.m_debugSourceInfos.Count()) + if (data.m_debugSourceInfos.getCount()) { _writeArrayChunk(Bin::CompressionType::None, Bin::kDebugStringFourCc, data.m_debugStringTable, stream); _writeArrayChunk(Bin::CompressionType::None, Bin::kDebugLineInfoFourCc, data.m_debugLineInfos, stream); @@ -1184,7 +1184,7 @@ class ListResizerForType: public ListResizer virtual void* setSize(size_t newSize) SLANG_OVERRIDE { - m_list.SetSize(UInt(newSize)); + m_list.setCount(UInt(newSize)); return (void*)m_list.begin(); } @@ -1215,7 +1215,7 @@ static Result _readArrayChunk(IRSerialBinary::CompressionType compressionType, c size_t payloadSize = header.m_chunk.m_size - (sizeof(header) - sizeof(Bin::Chunk)); List<uint8_t> compressedPayload; - compressedPayload.SetSize(payloadSize); + compressedPayload.setCount(payloadSize); stream->Read(compressedPayload.begin(), payloadSize); *numReadInOut += payloadSize; @@ -1294,7 +1294,7 @@ static Result _decodeInsts(IRSerialBinary::CompressionType compressionType, cons return SLANG_FAIL; } - const size_t numInsts = size_t(instsOut.Count()); + const size_t numInsts = size_t(instsOut.getCount()); IRSerialData::Inst* insts = instsOut.begin(); const uint8_t* encodeCur = encodeIn.begin(); @@ -1381,12 +1381,12 @@ Result _readInstArrayChunk(const IRSerialBinary::SlangHeader& slangHeader, const size_t payloadSize = header.m_chunk.m_size - (sizeof(header) - sizeof(Bin::Chunk)); List<uint8_t> compressedPayload; - compressedPayload.SetSize(payloadSize); + compressedPayload.setCount(payloadSize); stream->Read(compressedPayload.begin(), payloadSize); *numReadInOut += payloadSize; - arrayOut.SetSize(header.m_numEntries); + arrayOut.setCount(header.m_numEntries); SLANG_RETURN_ON_FAIL(_decodeInsts(compressionType, compressedPayload, arrayOut)); break; @@ -1561,7 +1561,7 @@ static SourceRange _toSourceRange(const IRSerialData::DebugSourceInfo& info) static int _findIndex(const List<IRSerialData::DebugSourceInfo>& infos, SourceLoc sourceLoc) { - const int numInfos = int(infos.Count()); + const int numInfos = int(infos.getCount()); for (int i = 0; i < numInfos; ++i) { if (_toSourceRange(infos[i]).contains(sourceLoc)) @@ -1598,11 +1598,11 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi List<IRInst*> insts; - const int numInsts = int(data.m_insts.Count()); + const Index numInsts = data.m_insts.getCount(); SLANG_ASSERT(numInsts > 0); - insts.SetSize(numInsts); + insts.setCount(numInsts); insts[0] = nullptr; // 0 holds null @@ -1622,7 +1622,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi insts[1] = moduleInst; } - for (int i = 2; i < numInsts; ++i) + for (Index i = 2; i < numInsts; ++i) { const Ser::Inst& srcInst = data.m_insts[i]; @@ -1714,7 +1714,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi } // Patch up the operands - for (int i = 1; i < numInsts; ++i) + for (Index i = 1; i < numInsts; ++i) { const Ser::Inst& srcInst = data.m_insts[i]; const IROp op((IROp)srcInst.m_op); @@ -1746,8 +1746,8 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi // Patch up the children { - const int numChildRuns = int(data.m_childRuns.Count()); - for (int i = 0; i < numChildRuns; i++) + const Index numChildRuns = data.m_childRuns.getCount(); + for (Index i = 0; i < numChildRuns; i++) { const auto& run = data.m_childRuns[i]; @@ -1763,10 +1763,10 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi } // Re-add source locations, if they are defined - if (int(m_serialData->m_rawSourceLocs.Count()) == numInsts) + if (m_serialData->m_rawSourceLocs.getCount() == numInsts) { const Ser::RawSourceLoc* srcLocs = m_serialData->m_rawSourceLocs.begin(); - for (int i = 1; i < numInsts; ++i) + for (Index i = 1; i < numInsts; ++i) { IRInst* dstInst = insts[i]; @@ -1774,7 +1774,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi } } - if (sourceManager && m_serialData->m_debugSourceInfos.Count()) + if (sourceManager && m_serialData->m_debugSourceInfos.getCount()) { List<UnownedStringSlice> debugStringSlices; SerialStringTableUtil::decodeStringTable(m_serialData->m_debugStringTable, debugStringSlices); @@ -1786,13 +1786,13 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi const List<IRSerialData::DebugSourceInfo>& sourceInfos = m_serialData->m_debugSourceInfos; // Construct the source files - int numSourceFiles = int(sourceInfos.Count()); + Index numSourceFiles = sourceInfos.getCount(); // These hold the views (and SourceFile as there is only one SourceFile per view) in the same order as the sourceInfos List<SourceView*> sourceViews; - sourceViews.SetSize(numSourceFiles); + sourceViews.setCount(numSourceFiles); - for (int i = 0; i < numSourceFiles; ++i) + for (Index i = 0; i < numSourceFiles; ++i) { const IRSerialData::DebugSourceInfo& srcSourceInfo = sourceInfos[i]; @@ -1807,8 +1807,8 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi List<IRSerialData::DebugLineInfo> lineInfos; // Add the adjusted lines { - lineInfos.SetSize(srcSourceInfo.m_numAdjustedLineInfos); - IRSerialData::DebugAdjustedLineInfo* srcAdjustedLineInfos = m_serialData->m_debugAdjustedLineInfos.Buffer() + srcSourceInfo.m_adjustedLineInfosStartIndex; + lineInfos.setCount(srcSourceInfo.m_numAdjustedLineInfos); + const IRSerialData::DebugAdjustedLineInfo* srcAdjustedLineInfos = m_serialData->m_debugAdjustedLineInfos.getBuffer() + srcSourceInfo.m_adjustedLineInfosStartIndex; const int numAdjustedLines = int(srcSourceInfo.m_numAdjustedLineInfos); for (int j = 0; j < numAdjustedLines; ++j) { @@ -1816,22 +1816,22 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi } } // Add regular lines - lineInfos.AddRange(m_serialData->m_debugLineInfos.Buffer() + srcSourceInfo.m_lineInfosStartIndex, srcSourceInfo.m_numLineInfos); + lineInfos.addRange(m_serialData->m_debugLineInfos.getBuffer() + srcSourceInfo.m_lineInfosStartIndex, srcSourceInfo.m_numLineInfos); // Put in sourceloc order - lineInfos.Sort(); + lineInfos.sort(); List<uint32_t> lineBreakOffsets; // We can now set up the line breaks array const int numLines = int(srcSourceInfo.m_numLines); - lineBreakOffsets.SetSize(numLines); + lineBreakOffsets.setCount(numLines); { - const int numLineInfos = int(lineInfos.Count()); - int lineIndex = 0; + const Index numLineInfos = lineInfos.getCount(); + Index lineIndex = 0; // Every line up and including should hold the same offset - for (int lineInfoIndex = 0; lineInfoIndex < numLineInfos; ++lineInfoIndex) + for (Index lineInfoIndex = 0; lineInfoIndex < numLineInfos; ++lineInfoIndex) { const auto& lineInfo = lineInfos[lineInfoIndex]; @@ -1857,7 +1857,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi } } - sourceFile->setLineBreakOffsets(lineBreakOffsets.Buffer(), lineBreakOffsets.Count()); + sourceFile->setLineBreakOffsets(lineBreakOffsets.getBuffer(), lineBreakOffsets.getCount()); if (srcSourceInfo.m_numAdjustedLineInfos) { @@ -1865,12 +1865,12 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi int numEntries = int(srcSourceInfo.m_numAdjustedLineInfos); - adjustedLineInfos.AddRange(m_serialData->m_debugAdjustedLineInfos.Buffer() + srcSourceInfo.m_adjustedLineInfosStartIndex, numEntries); - adjustedLineInfos.Sort(); + adjustedLineInfos.addRange(m_serialData->m_debugAdjustedLineInfos.getBuffer() + srcSourceInfo.m_adjustedLineInfosStartIndex, numEntries); + adjustedLineInfos.sort(); // Work out the views adjustments, and place in dstEntries List<SourceView::Entry> dstEntries; - dstEntries.SetSize(numEntries); + dstEntries.setCount(numEntries); const uint32_t sourceLocOffset = uint32_t(sourceView->getRange().begin.getRaw()); @@ -1885,7 +1885,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi } // Set the adjustments on the view - sourceView->setEntries(dstEntries.Buffer(), dstEntries.Count()); + sourceView->setEntries(dstEntries.getBuffer(), dstEntries.getCount()); } sourceViews[i] = sourceView; @@ -1895,14 +1895,14 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi { List<IRSerialData::SourceLocRun> sourceRuns(m_serialData->m_debugSourceLocRuns); // They are now in source location order - sourceRuns.Sort(); + sourceRuns.sort(); // Just guess initially 0 for the source file that contains the initial run SourceRange range; int fixSourceLoc = _calcFixSourceLoc(sourceInfos[0], sourceViews[0], range); - const int numRuns = int(sourceRuns.Count()); - for (int i = 0; i < numRuns; ++i) + const Index numRuns = sourceRuns.getCount(); + for (Index i = 0; i < numRuns; ++i) { const auto& run = sourceRuns[i]; const SourceLoc srcSourceLoc = SourceLoc::fromRaw(run.m_sourceLoc); @@ -1922,8 +1922,8 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi // Work out the fixed source location SourceLoc sourceLoc = SourceLoc::fromRaw(int(run.m_sourceLoc) + fixSourceLoc); - SLANG_ASSERT(uint32_t(run.m_startInstIndex) + run.m_numInst <= insts.Count()); - IRInst** dstInsts = insts.Buffer() + int(run.m_startInstIndex); + SLANG_ASSERT(Index(uint32_t(run.m_startInstIndex) + run.m_numInst) <= insts.getCount()); + IRInst** dstInsts = insts.getBuffer() + int(run.m_startInstIndex); const int runSize = int(run.m_numInst); for (int j = 0; j < runSize; ++j) @@ -1942,30 +1942,30 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi /* static */void IRSerialUtil::calcInstructionList(IRModule* module, List<IRInst*>& instsOut) { // We reserve 0 for null - instsOut.SetSize(1); + instsOut.setCount(1); instsOut[0] = nullptr; // Stack for parentInst List<IRInst*> parentInstStack; IRModuleInst* moduleInst = module->getModuleInst(); - parentInstStack.Add(moduleInst); + parentInstStack.add(moduleInst); // Add to list - instsOut.Add(moduleInst); + instsOut.add(moduleInst); // Traverse all of the instructions - while (parentInstStack.Count()) + while (parentInstStack.getCount()) { // If it's in the stack it is assumed it is already in the inst map - IRInst* parentInst = parentInstStack.Last(); - parentInstStack.RemoveLast(); + IRInst* parentInst = parentInstStack.getLast(); + parentInstStack.removeLast(); IRInstListBase childrenList = parentInst->getDecorationsAndChildren(); for (IRInst* child : childrenList) { - instsOut.Add(child); - parentInstStack.Add(child); + instsOut.add(child); + parentInstStack.add(child); } } } @@ -2015,7 +2015,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi List<IRInst*> readInsts; calcInstructionList(irReadModule, readInsts); - if (readInsts.Count() != originalInsts.Count()) + if (readInsts.getCount() != originalInsts.getCount()) { SLANG_ASSERT(!"Instruction counts don't match"); return SLANG_FAIL; @@ -2025,7 +2025,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi { SLANG_ASSERT(readInsts[0] == originalInsts[0]); // All the source locs should be identical - for (UInt i = 1; i < readInsts.Count(); ++i) + for (Index i = 1; i < readInsts.getCount(); ++i) { IRInst* origInst = originalInsts[i]; IRInst* readInst = readInsts[i]; @@ -2040,7 +2040,7 @@ static int _calcFixSourceLoc(const IRSerialData::DebugSourceInfo& info, SourceVi else if (optionFlags & IRSerialWriter::OptionFlag::DebugInfo) { // They should be on the same line nos - for (UInt i = 1; i < readInsts.Count(); ++i) + for (Index i = 1; i < readInsts.getCount(); ++i) { IRInst* origInst = originalInsts[i]; IRInst* readInst = readInsts[i]; |
