summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-06-17 13:08:27 -0700
committerGitHub <noreply@github.com>2020-06-17 13:08:27 -0700
commitcd7f01b63a52eaaad00088524801e502bcb0f168 (patch)
treea04b6d9f2f7f85466b537a8aedeb3795339fae71 /source/slang/slang-emit.cpp
parentca503d48bff31d3990d4740751d5f6a4a48bfe5a (diff)
Generate dynamic C++ code for the minimal test case. (#1391)
* Add IR pass to lower generics into ordinary functions. * Fix project files * Emit dynamic C++ code for simple generics and witness tables. Fixes #1386. * Remove -dump-ir flag. * Fixups.
Diffstat (limited to 'source/slang/slang-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index 2212d5d5a..260a862ae 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -11,6 +11,7 @@
#include "slang-ir-glsl-legalize.h"
#include "slang-ir-insts.h"
#include "slang-ir-link.h"
+#include "slang-ir-lower-generics.h"
#include "slang-ir-restructure.h"
#include "slang-ir-restructure-scoping.h"
#include "slang-ir-specialize.h"
@@ -273,6 +274,18 @@ Result linkAndOptimizeIR(
if (!compileRequest->allowDynamicCode)
specializeModule(irModule);
+ switch (target)
+ {
+ case CodeGenTarget::CPPSource:
+ // For targets that supports dynamic dispatch, we need to lower the
+ // generics / interface types to ordinary functions and types using
+ // function pointers.
+ lowerGenerics(irModule);
+ break;
+ default:
+ break;
+ }
+
// Debugging code for IR transformations...
#if 0
dumpIRIfEnabled(compileRequest, irModule, "SPECIALIZED");
@@ -389,6 +402,7 @@ Result linkAndOptimizeIR(
#if 0
dumpIRIfEnabled(compileRequest, irModule, "AFTER RESOURCE SPECIALIZATION");
#endif
+
validateIRModuleIfEnabled(compileRequest, irModule);
// For HLSL (and fxc/dxc) only, we need to "wrap" any
@@ -558,11 +572,14 @@ Result linkAndOptimizeIR(
break;
}
- // For all targets that don't support true dynamic dispatch through
- // witness tables (that is all targets at present), we need
- // to eliminate witness tables from the IR so that they
- // don't keep symbols live that we don't actually need.
- stripWitnessTables(irModule);
+ if (!compileRequest->allowDynamicCode)
+ {
+ // For all targets that don't support true dynamic dispatch through
+ // witness tables, we need to eliminate witness tables from the IR so
+ // that they don't keep symbols live that we don't actually need.
+ stripWitnessTables(irModule);
+ }
+
#if 0
dumpIRIfEnabled(compileRequest, irModule, "AFTER STRIP WITNESS TABLES");
#endif