diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-01-06 15:36:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-06 15:36:11 -0500 |
| commit | 0c87001d7fb9dabaa17f9784e99d7438592d2373 (patch) | |
| tree | 0cd893463a0734928a45e63850c1fabb8e4d4129 /source/slang/slang-ir-type-set.cpp | |
| parent | 79b52bb8ac2a6059f5bbdc17be22725400b74aad (diff) | |
Fix scoping issue around use of IRTypeSet (#1160)
* WIP use IRTypeSet in CPPSourceEmitter - doesn't work because of a cloning issue, causing a crash on exit.
* Fix destruction of module issue for IRTypeSet usage in CPPEmitter.
* Fix out definition emitting ordering that was removed.
* Disable cuda output test.
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()); +} + } |
