summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir.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-ir.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-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 4d507de41..34ea23b85 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -2307,6 +2307,16 @@ namespace Slang
(IRInst* const*) paramTypes);
}
+ IRWitnessTableType* IRBuilder::getWitnessTableType(
+ IRType* baseType)
+ {
+ return (IRWitnessTableType*)findOrEmitHoistableInst(
+ nullptr,
+ kIROp_WitnessTableType,
+ 1,
+ (IRInst* const*)&baseType);
+ }
+
IRConstantBufferType* IRBuilder::getConstantBufferType(IRType* elementType)
{
IRInst* operands[] = { elementType };
@@ -2465,7 +2475,7 @@ namespace Slang
IRInst* IRBuilder::emitExtractExistentialWitnessTable(
IRInst* existentialValue)
{
- auto type = getWitnessTableType();
+ auto type = getWitnessTableType(existentialValue->getDataType());
auto inst = createInst<IRInst>(
this,
kIROp_ExtractExistentialWitnessTable,
@@ -2775,7 +2785,7 @@ namespace Slang
IRWitnessTable* witnessTable = createInst<IRWitnessTable>(
this,
kIROp_WitnessTable,
- nullptr,
+ getWitnessTableType(baseType),
baseType);
addGlobalValue(this, witnessTable);
return witnessTable;