summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index f8b14b0f3..a1235f03a 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -3,6 +3,7 @@
#include "../core/slang-writer.h"
#include "ir-dce.h"
+#include "ir-existential.h"
#include "ir-insts.h"
#include "ir-restructure.h"
#include "ir-restructure-scoping.h"
@@ -6532,6 +6533,26 @@ String emitEntryPoint(
// un-specialized IR.
dumpIRIfEnabled(compileRequest, irModule);
+ // Any code that makes use of existential (interface) types
+ // needs to be simplified to use concrete types instead,
+ // wherever this is possible.
+ //
+ // Note: we are applying this *before* doing specialization
+ // of generics because this pass could expose concrete
+ // types and/or witness tables that allow for further
+ // specialization.
+ //
+ // TODO: Simplification of existential-based and generics-based
+ // code may each open up opportunities for the other, so
+ // in the long run these will need to be merged into a
+ // single pass that looks for all simplification opportunities.
+ //
+ // TODO: We also need a legalization pass that will "expose"
+ // existential values that are nested inside of other types,
+ // so that the simplifications can be applied.
+ //
+ simplifyExistentialTypes(irModule);
+
// Next, we need to ensure that the code we emit for
// the target doesn't contain any operations that would
// be illegal on the target platform. For example,
@@ -6540,6 +6561,8 @@ String emitEntryPoint(
//
specializeGenerics(irModule, sharedContext.target);
+
+
// Debugging code for IR transformations...
#if 0
dumpIRIfEnabled(compileRequest, irModule, "SPECIALIZED");