diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-06-22 15:07:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-22 15:07:31 -0400 |
| commit | 769c7fdd19ea579770baac7b6d5e16d6406a8013 (patch) | |
| tree | a0f04c668911a2b3b58e0fc89f5bb765540226bd /source/slang/slang-lower-to-ir.cpp | |
| parent | ac541d45fafde340b141172cf76d003ff70d471e (diff) | |
[branch] and [flatten] support (#2928)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Small fixes and improvements around reflection tool.
* Make PrettyWriter printing a class.
* Add HLSL output support for [flatten] and [branch]
* Handle [branch] on switch.
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 937262758..5df1db03b 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -5075,13 +5075,15 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor> auto irCond = getSimpleVal(context, lowerRValueExpr(context, condExpr)); + IRInst* ifInst = nullptr; + if (elseStmt) { auto thenBlock = createBlock(); auto elseBlock = createBlock(); auto afterBlock = createBlock(); - builder->emitIfElse(irCond, thenBlock, elseBlock, afterBlock); + ifInst = builder->emitIfElse(irCond, thenBlock, elseBlock, afterBlock); insertBlock(thenBlock); lowerStmt(context, thenStmt); @@ -5097,13 +5099,22 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor> auto thenBlock = createBlock(); auto afterBlock = createBlock(); - builder->emitIf(irCond, thenBlock, afterBlock); + ifInst = builder->emitIf(irCond, thenBlock, afterBlock); insertBlock(thenBlock); lowerStmt(context, thenStmt); insertBlock(afterBlock); } + + if (stmt->findModifier<FlattenAttribute>()) + { + builder->addDecoration(ifInst, kIROp_FlattenDecoration); + } + if (stmt->findModifier<BranchAttribute>()) + { + builder->addDecoration(ifInst, kIROp_BranchDecoration); + } } void addLoopDecorations( @@ -5828,7 +5839,7 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor> // prepared to emit the `switch` instruction // itself. builder->setInsertInto(initialBlock); - builder->emitSwitch( + auto switchInst = builder->emitSwitch( conditionVal, breakLabel, defaultLabel, @@ -5840,6 +5851,12 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor> // This is the block that subsequent code will go into. insertBlock(breakLabel); context->shared->breakLabels.remove(stmt); + + // If there is the branch attribute output the IR decoration + if (stmt->hasModifier<BranchAttribute>()) + { + builder->addDecoration(switchInst, kIROp_BranchDecoration); + } } }; |
