diff options
Diffstat (limited to 'source/slang/ir.cpp')
| -rw-r--r-- | source/slang/ir.cpp | 69 |
1 files changed, 19 insertions, 50 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 634632f0d..824af64ae 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -170,8 +170,6 @@ namespace Slang break; case kIROp_unconditionalBranch: - case kIROp_break: - case kIROp_continue: case kIROp_loop: // unconditonalBranch <block> begin = args + 0; @@ -179,9 +177,7 @@ namespace Slang break; case kIROp_conditionalBranch: - case kIROp_if: case kIROp_ifElse: - case kIROp_loopTest: // conditionalBranch <condition> <trueBlock> <falseBlock> begin = args + 1; end = begin + 2; @@ -401,12 +397,8 @@ namespace Slang case kIROp_ReturnVoid: case kIROp_unconditionalBranch: case kIROp_conditionalBranch: - case kIROp_break: - case kIROp_continue: case kIROp_loop: - case kIROp_if: case kIROp_ifElse: - case kIROp_loopTest: case kIROp_discard: case kIROp_switch: case kIROp_unreachable: @@ -1302,6 +1294,15 @@ namespace Slang return nullptr; } + // Ugly special case: the result of loading from `groupshared` + // memory should not itself be `groupshared`. + // + // TODO: Should this generalize to any "rate-qualified" type? + if(auto rateType = valueType->As<GroupSharedType>()) + { + valueType = rateType->valueType; + } + auto inst = createInst<IRLoad>( this, kIROp_Load, @@ -1526,25 +1527,13 @@ namespace Slang IRInst* IRBuilder::emitBreak( IRBlock* target) { - auto inst = createInst<IRBreak>( - this, - kIROp_break, - nullptr, - target); - addInst(inst); - return inst; + return emitBranch(target); } IRInst* IRBuilder::emitContinue( IRBlock* target) { - auto inst = createInst<IRContinue>( - this, - kIROp_continue, - nullptr, - target); - addInst(inst); - return inst; + return emitBranch(target); } IRInst* IRBuilder::emitLoop( @@ -1583,17 +1572,18 @@ namespace Slang return inst; } - IRInst* IRBuilder::emitIf( + IRInst* IRBuilder::emitIfElse( IRValue* val, IRBlock* trueBlock, + IRBlock* falseBlock, IRBlock* afterBlock) { - IRValue* args[] = { val, trueBlock, afterBlock }; + IRValue* args[] = { val, trueBlock, falseBlock, afterBlock }; UInt argCount = sizeof(args) / sizeof(args[0]); - auto inst = createInst<IRIf>( + auto inst = createInst<IRIfElse>( this, - kIROp_if, + kIROp_ifElse, nullptr, argCount, args); @@ -1601,23 +1591,12 @@ namespace Slang return inst; } - IRInst* IRBuilder::emitIfElse( + IRInst* IRBuilder::emitIf( IRValue* val, IRBlock* trueBlock, - IRBlock* falseBlock, IRBlock* afterBlock) { - IRValue* args[] = { val, trueBlock, falseBlock, afterBlock }; - UInt argCount = sizeof(args) / sizeof(args[0]); - - auto inst = createInst<IRIfElse>( - this, - kIROp_ifElse, - nullptr, - argCount, - args); - addInst(inst); - return inst; + return emitIfElse(val, trueBlock, afterBlock, afterBlock); } IRInst* IRBuilder::emitLoopTest( @@ -1625,17 +1604,7 @@ namespace Slang IRBlock* bodyBlock, IRBlock* breakBlock) { - IRValue* args[] = { val, bodyBlock, breakBlock }; - UInt argCount = sizeof(args) / sizeof(args[0]); - - auto inst = createInst<IRLoopTest>( - this, - kIROp_loopTest, - nullptr, - argCount, - args); - addInst(inst); - return inst; + return emitIfElse(val, bodyBlock, breakBlock, bodyBlock); } IRInst* IRBuilder::emitSwitch( |
