From 3d4eaf3c9b13e32c4e4d7737f17805503cddcb0b Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 15 Jan 2018 18:15:49 -0500 Subject: Support transitive interfaces This commit is a bunch of quick hacks to get transitive interfaces to work. The idea is for each concrete type we create one giant witness table that contains entries for all the transitively reachable interface requirements, and then create one copy of that witness table for each interface it implements. `DoLocalLookupImpl` now also looks up in inherited interface decles when looking up for a symbol in an interface decl. When visiting `InheritanceDecl` in `lower-to-ir`, create copies of the giant witness table for each transitively inherited interface, so that these witness tables can be found later when the IR is specialized. Re-enable the `copy all witness tables` hack in `specializeIRForEntryPoint` to ensure those transitive witness tables are copied over. --- source/slang/ir.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/slang/ir.cpp') diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 46eff33e9..17ba14c6e 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -3690,12 +3690,12 @@ namespace Slang cloneFunctionCommon(context, clonedFunc, originalFunc); // for now, clone all unreferenced witness tables - /*for (auto gv = context->getOriginalModule()->getFirstGlobalValue(); + for (auto gv = context->getOriginalModule()->getFirstGlobalValue(); gv; gv = gv->getNextValue()) { if (gv->op == kIROp_witness_table) cloneGlobalValue(context, (IRWitnessTable*)gv); - }*/ + } // We need to attach the layout information for // the entry point to this declaration, so that @@ -4746,7 +4746,9 @@ namespace Slang // // We will first find or construct a specialized version // of the callee funciton/ + auto oldFunc = dumpIRFunc(genericFunc); auto specFunc = getSpecializedFunc(sharedContext, genericFunc, specDeclRef); + auto newFunc = dumpIRFunc(specFunc); // // Then we will replace the use sites for the `specialize` // instruction with uses of the specialized function. -- cgit v1.2.3 From 513f56b85e3678bbaf40f74397e8d9a864761c08 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 15 Jan 2018 18:30:11 -0500 Subject: cleanup debug code --- source/slang/ir.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/slang/ir.cpp') diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 17ba14c6e..45ad71b67 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -4746,9 +4746,7 @@ namespace Slang // // We will first find or construct a specialized version // of the callee funciton/ - auto oldFunc = dumpIRFunc(genericFunc); auto specFunc = getSpecializedFunc(sharedContext, genericFunc, specDeclRef); - auto newFunc = dumpIRFunc(specFunc); // // Then we will replace the use sites for the `specialize` // instruction with uses of the specialized function. -- cgit v1.2.3