summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-util.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-04-12 22:58:22 -0700
committerGitHub <noreply@github.com>2023-04-12 22:58:22 -0700
commitca7bf79df3a3f5f4494912cb0572c36662755b9d (patch)
tree64b14034326be8285c0265e74ad3ed11e29ff062 /source/slang/slang-ir-util.cpp
parent12ec9b832fc74faba7162e54e04f7f48878ea88e (diff)
Combine lookupWitness lowering with specialization. (#2794)
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
-rw-r--r--source/slang/slang-ir-util.cpp23
1 files changed, 23 insertions, 0 deletions
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<IRInterfaceRequirementEntry>(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;