summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-07-13 15:16:09 -0700
committerGitHub <noreply@github.com>2020-07-13 15:16:09 -0700
commit48f26ef082fa3b0c2a02dc57585f7e43210bbb63 (patch)
treee3e13e8034c0f2efe1454a51b4df0290056dae9f /source/slang/slang-ir.cpp
parent249f48dbb5e240c713661be969a6939ec57561e5 (diff)
Dynamic code gen for functions returning generic types. (#1439)
* Dynamic code gen for functions returning generic types. * Add expected test result.
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index b2ddc8ed3..efb8b3b27 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -343,6 +343,25 @@ namespace Slang
}
}
+ // Similar to addParam, but instead of appending `param` to the end
+ // of the parameter list, this function inserts `param` before the
+ // head of the list.
+ void IRBlock::insertParamAtHead(IRParam* param)
+ {
+ if (auto firstParam = getFirstParam())
+ {
+ param->insertBefore(firstParam);
+ }
+ else if (auto firstOrdinary = getFirstOrdinaryInst())
+ {
+ param->insertBefore(firstOrdinary);
+ }
+ else
+ {
+ param->insertAtEnd(this);
+ }
+ }
+
IRInst* IRBlock::getFirstOrdinaryInst()
{
// Find the last parameter (if any) of the block
@@ -3030,6 +3049,17 @@ namespace Slang
return param;
}
+ IRParam* IRBuilder::emitParamAtHead(
+ IRType* type)
+ {
+ auto param = createParam(type);
+ if (auto bb = getBlock())
+ {
+ bb->insertParamAtHead(param);
+ }
+ return param;
+ }
+
IRVar* IRBuilder::emitVar(
IRType* type)
{