diff options
Diffstat (limited to 'source/slang/slang-ir-type-set.cpp')
| -rw-r--r-- | source/slang/slang-ir-type-set.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/source/slang/slang-ir-type-set.cpp b/source/slang/slang-ir-type-set.cpp index 7beeaced4..a4ebf8242 100644 --- a/source/slang/slang-ir-type-set.cpp +++ b/source/slang/slang-ir-type-set.cpp @@ -23,6 +23,22 @@ IRTypeSet::IRTypeSet(Session* session) IRTypeSet::~IRTypeSet() { + _clearTypes(); +} + +void IRTypeSet::clear() +{ + _clearTypes(); + + m_cloneMap.Clear(); + + m_module = m_builder.createModule(); + m_sharedBuilder.module = m_module; + m_builder.setInsertInto(m_module->getModuleInst()); +} + +void IRTypeSet::_clearTypes() +{ List<IRType*> types; getTypes(types); @@ -226,4 +242,51 @@ void IRTypeSet::addVectorForMatrixTypes() } } +static bool _hasNominalOperand(IRInst* inst) +{ + const Index operandCount = Index(inst->getOperandCount()); + auto operands = inst->getOperands(); + + for (Index i = 0; i < operandCount; ++i) + { + IRInst* operand = operands[i].get(); + if (isNominalOp(operand->op)) + { + return true; + } + } + + return false; +} + +void IRTypeSet::_addAllBuiltinTypesRec(IRInst* inst) +{ + for (IRInst* child = inst->getFirstDecorationOrChild(); child; child = child->getNextInst()) + { + IRType* type = nullptr; + + if (auto vectorType = as<IRVectorType>(child)) + { + type = vectorType; + } + else if (auto matrixType = as<IRMatrixType>(child)) + { + type = matrixType; + } + if (type && !_hasNominalOperand(type)) + { + add(type); + } + else + { + _addAllBuiltinTypesRec(child); + } + } +} + +void IRTypeSet::addAllBuiltinTypes(IRModule* module) +{ + _addAllBuiltinTypesRec(module->getModuleInst()); +} + } |
