diff options
Diffstat (limited to 'source/slang/slang-ir.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 30 |
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) { |
