summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 150a5d544..5015fda9d 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -636,6 +636,33 @@ namespace Slang
block->insertAtEnd(this);
}
+ void fixUpFuncType(IRFunc* func)
+ {
+ SLANG_ASSERT(func);
+
+ auto irModule = func->getModule();
+ SLANG_ASSERT(irModule);
+
+ SharedIRBuilder sharedBuilder;
+ sharedBuilder.module = irModule;
+
+ IRBuilder builder;
+ builder.sharedBuilder = &sharedBuilder;
+
+ builder.setInsertBefore(func);
+
+ List<IRType*> paramTypes;
+ for(auto param : func->getParams())
+ {
+ paramTypes.add(param->getFullType());
+ }
+
+ auto resultType = func->getResultType();
+
+ auto funcType = builder.getFuncType(paramTypes, resultType);
+ builder.setDataType(func, funcType);
+ }
+
//
bool isTerminatorInst(IROp op)
@@ -1828,6 +1855,9 @@ namespace Slang
UInt slotArgCount,
IRInst* const* slotArgs)
{
+ if(slotArgCount == 0)
+ return (IRType*) baseType;
+
// If we are trying to bind an interface type, then
// we will go ahead and simplify the instruction
// away impmediately.
@@ -1859,6 +1889,9 @@ namespace Slang
UInt slotArgCount,
IRUse const* slotArgUses)
{
+ if(slotArgCount == 0)
+ return (IRType*) baseType;
+
List<IRInst*> slotArgs;
for( UInt ii = 0; ii < slotArgCount; ++ii )
{
@@ -2091,6 +2124,9 @@ namespace Slang
UInt slotArgCount,
IRInst* const* slotArgs)
{
+ if(slotArgCount == 0)
+ return value;
+
// If we are wrapping a single concrete value into
// an interface type, then this is really a `makeExistential`
//
@@ -3978,13 +4014,14 @@ namespace Slang
void IRInst::insertAfter(IRInst* other)
{
SLANG_ASSERT(other);
-
+ removeFromParent();
_insertAt(other, other->getNextInst(), other->getParent());
}
void IRInst::insertAtEnd(IRInst* newParent)
{
SLANG_ASSERT(newParent);
+ removeFromParent();
_insertAt(newParent->getLastDecorationOrChild(), nullptr, newParent);
}