diff options
| author | Yong He <yonghe@outlook.com> | 2020-11-06 10:26:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-06 10:26:27 -0800 |
| commit | 444ff4d8fdeb721b94a9424d03c162f43fb217c9 (patch) | |
| tree | 7896e00e223d9b1a66a8479f510e60136c5713c3 /source/slang/slang-ir-specialize-dispatch.cpp | |
| parent | 94861d5d8afdf216c0a507af24fdbe9fda4b66d7 (diff) | |
Specialize witness table lookups. (#1596)
* Specialize witness table lookups.
* Remove generated files from vcxproj
* Fix call to generic interface methods.
Diffstat (limited to 'source/slang/slang-ir-specialize-dispatch.cpp')
| -rw-r--r-- | source/slang/slang-ir-specialize-dispatch.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/source/slang/slang-ir-specialize-dispatch.cpp b/source/slang/slang-ir-specialize-dispatch.cpp index ddbb743a8..98a0ba3b7 100644 --- a/source/slang/slang-ir-specialize-dispatch.cpp +++ b/source/slang/slang-ir-specialize-dispatch.cpp @@ -6,29 +6,13 @@ namespace Slang { -IRInst* findWitnessTableEntry(IRWitnessTable* table, IRInst* key) -{ - for (auto entry : table->getEntries()) - { - if (entry->getRequirementKey() == key) - return entry->getSatisfyingVal(); - } - return nullptr; -} - IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, IRFunc* dispatchFunc) { auto witnessTableType = cast<IRFuncType>(dispatchFunc->getDataType())->getParamType(0); // Collect all witness tables of `witnessTableType` in current module. - List<IRWitnessTable*> witnessTables; - for (auto globalInst : sharedContext->module->getGlobalInsts()) - { - if (globalInst->op == kIROp_WitnessTable && globalInst->getDataType() == witnessTableType) - { - witnessTables.add(cast<IRWitnessTable>(globalInst)); - } - } + List<IRWitnessTable*> witnessTables = sharedContext->getWitnessTablesFromInterfaceType( + cast<IRWitnessTableType>(witnessTableType)->getConformanceType()); SLANG_ASSERT(dispatchFunc->getFirstBlock() == dispatchFunc->getLastBlock()); auto block = dispatchFunc->getFirstBlock(); @@ -119,7 +103,7 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, builder->setInsertInto(defaultBlock); } - auto callee = findWitnessTableEntry(witnessTable, requirementKey); + auto callee = sharedContext->findWitnessTableEntry(witnessTable, requirementKey); SLANG_ASSERT(callee); auto specializedCallInst = builder->emitCallInst(callInst->getFullType(), callee, params); if (callInst->getDataType()->op == kIROp_VoidType) |
