diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang/slang-serialize-ir-types.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-serialize-ir-types.cpp')
| -rw-r--r-- | source/slang/slang-serialize-ir-types.cpp | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/source/slang/slang-serialize-ir-types.cpp b/source/slang/slang-serialize-ir-types.cpp index cceb72463..e7d42b642 100644 --- a/source/slang/slang-serialize-ir-types.cpp +++ b/source/slang/slang-serialize-ir-types.cpp @@ -1,48 +1,52 @@ // slang-serialize-ir-types.cpp #include "slang-serialize-ir-types.h" -#include "../core/slang-text-io.h" #include "../core/slang-byte-encode-util.h" - -#include "slang-ir-insts.h" - #include "../core/slang-math.h" +#include "../core/slang-text-io.h" +#include "slang-ir-insts.h" -namespace Slang { +namespace Slang +{ -/* Note that an IRInst can be derived from, but when it derived from it's new members are IRUse variables, and they in -effect alias over the operands - and reflected in the operand count. There _could_ be other members after these IRUse -variables, but only a few types include extra data, and these do not have any operands: +/* Note that an IRInst can be derived from, but when it derived from it's new members are IRUse +variables, and they in effect alias over the operands - and reflected in the operand count. There +_could_ be other members after these IRUse variables, but only a few types include extra data, and +these do not have any operands: * IRConstant - Needs special-case handling * IRModuleInst - Presumably we can just set to the module pointer on reconstruction -Note! That on an IRInst there is an IRType* variable (accessed as getFullType()). As it stands it may NOT actually point -to an IRType derived type. Its 'ok' as long as it's an instruction that can be used in the place of the type. So this code does not -bother to check if it's correct, and just casts it. +Note! That on an IRInst there is an IRType* variable (accessed as getFullType()). As it stands it +may NOT actually point to an IRType derived type. Its 'ok' as long as it's an instruction that can +be used in the place of the type. So this code does not bother to check if it's correct, and just +casts it. */ -/* static */const IRSerialData::PayloadInfo IRSerialData::s_payloadInfos[int(Inst::PayloadType::CountOf)] = -{ - { 0, 0 }, // Empty - { 1, 0 }, // Operand_1 - { 2, 0 }, // Operand_2 - { 1, 0 }, // OperandAndUInt32, - { 0, 0 }, // OperandExternal - This isn't correct, Operand has to be specially handled - { 0, 1 }, // String_1, - { 0, 2 }, // String_2, - { 0, 0 }, // UInt32, - { 0, 0 }, // Float64, - { 0, 0 } // Int64, +/* static */ const IRSerialData::PayloadInfo + IRSerialData::s_payloadInfos[int(Inst::PayloadType::CountOf)] = { + {0, 0}, // Empty + {1, 0}, // Operand_1 + {2, 0}, // Operand_2 + {1, 0}, // OperandAndUInt32, + {0, 0}, // OperandExternal - This isn't correct, Operand has to be specially handled + {0, 1}, // String_1, + {0, 2}, // String_2, + {0, 0}, // UInt32, + {0, 0}, // Float64, + {0, 0} // Int64, }; // Check all compressible chunk ids, start with upper case 'S' SLANG_COMPILE_TIME_ASSERT(SLANG_FOUR_CC_GET_FIRST_CHAR(IRSerialBinary::kInstFourCc) == 'S'); SLANG_COMPILE_TIME_ASSERT(SLANG_FOUR_CC_GET_FIRST_CHAR(IRSerialBinary::kChildRunFourCc) == 'S'); -SLANG_COMPILE_TIME_ASSERT(SLANG_FOUR_CC_GET_FIRST_CHAR(IRSerialBinary::kExternalOperandsFourCc) == 'S'); +SLANG_COMPILE_TIME_ASSERT( + SLANG_FOUR_CC_GET_FIRST_CHAR(IRSerialBinary::kExternalOperandsFourCc) == 'S'); // Compressed version starts with 's' -SLANG_COMPILE_TIME_ASSERT(SLANG_FOUR_CC_GET_FIRST_CHAR(SLANG_MAKE_COMPRESSED_FOUR_CC(IRSerialBinary::kInstFourCc)) == 's'); +SLANG_COMPILE_TIME_ASSERT( + SLANG_FOUR_CC_GET_FIRST_CHAR(SLANG_MAKE_COMPRESSED_FOUR_CC(IRSerialBinary::kInstFourCc)) == + 's'); struct PrefixString; @@ -56,15 +60,12 @@ static size_t _calcArraySize(const List<T>& list) size_t IRSerialData::calcSizeInBytes() const { - return - _calcArraySize(m_insts) + - _calcArraySize(m_childRuns) + - _calcArraySize(m_externalOperands) + - _calcArraySize(m_stringTable) + - /* Raw source locs */ - _calcArraySize(m_rawSourceLocs) + - /* Debug */ - _calcArraySize(m_debugSourceLocRuns); + return _calcArraySize(m_insts) + _calcArraySize(m_childRuns) + + _calcArraySize(m_externalOperands) + _calcArraySize(m_stringTable) + + /* Raw source locs */ + _calcArraySize(m_rawSourceLocs) + + /* Debug */ + _calcArraySize(m_debugSourceLocRuns); } IRSerialData::IRSerialData() @@ -83,20 +84,20 @@ void IRSerialData::clear() m_rawSourceLocs.clear(); m_stringTable.clear(); - + m_debugSourceLocRuns.clear(); } bool IRSerialData::operator==(const ThisType& rhs) const { return (this == &rhs) || - (SerialListUtil::isEqual(m_insts, rhs.m_insts) && - SerialListUtil::isEqual(m_childRuns, rhs.m_childRuns) && - SerialListUtil::isEqual(m_externalOperands, rhs.m_externalOperands) && - SerialListUtil::isEqual(m_rawSourceLocs, rhs.m_rawSourceLocs) && - SerialListUtil::isEqual(m_stringTable, rhs.m_stringTable) && - /* Debug */ - SerialListUtil::isEqual(m_debugSourceLocRuns, rhs.m_debugSourceLocRuns)); + (SerialListUtil::isEqual(m_insts, rhs.m_insts) && + SerialListUtil::isEqual(m_childRuns, rhs.m_childRuns) && + SerialListUtil::isEqual(m_externalOperands, rhs.m_externalOperands) && + SerialListUtil::isEqual(m_rawSourceLocs, rhs.m_rawSourceLocs) && + SerialListUtil::isEqual(m_stringTable, rhs.m_stringTable) && + /* Debug */ + SerialListUtil::isEqual(m_debugSourceLocRuns, rhs.m_debugSourceLocRuns)); } } // namespace Slang |
