From ca7bf79df3a3f5f4494912cb0572c36662755b9d Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 12 Apr 2023 22:58:22 -0700 Subject: Combine lookupWitness lowering with specialization. (#2794) --- source/slang/slang-ir-util.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/slang/slang-ir-util.cpp') diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index c5cebb8b5..83f6735bd 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -698,6 +698,29 @@ bool isPureFunctionalCall(IRCall* call) return false; } +IRInst* findInterfaceRequirement(IRInterfaceType* type, IRInst* key) +{ + for (UInt i = 0; i < type->getOperandCount(); i++) + { + if (auto req = as(type->getOperand(i))) + { + if (req->getRequirementKey() == key) + return req->getRequirementVal(); + } + } + return nullptr; +} + +IRInst* findWitnessTableEntry(IRWitnessTable* table, IRInst* key) +{ + for (auto entry : table->getEntries()) + { + if (entry->getRequirementKey() == key) + return entry->getSatisfyingVal(); + } + return nullptr; +} + struct GenericChildrenMigrationContextImpl { IRCloneEnv cloneEnv; -- cgit v1.2.3