From 444ff4d8fdeb721b94a9424d03c162f43fb217c9 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 6 Nov 2020 10:26:27 -0800 Subject: Specialize witness table lookups. (#1596) * Specialize witness table lookups. * Remove generated files from vcxproj * Fix call to generic interface methods. --- source/slang/slang-ir-specialize-dispatch.cpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'source/slang/slang-ir-specialize-dispatch.cpp') 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(dispatchFunc->getDataType())->getParamType(0); // Collect all witness tables of `witnessTableType` in current module. - List witnessTables; - for (auto globalInst : sharedContext->module->getGlobalInsts()) - { - if (globalInst->op == kIROp_WitnessTable && globalInst->getDataType() == witnessTableType) - { - witnessTables.add(cast(globalInst)); - } - } + List witnessTables = sharedContext->getWitnessTablesFromInterfaceType( + cast(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) -- cgit v1.2.3